Page 1 of 1
periodic timer interrupt
Posted: Thu Aug 09, 2018 2:00 am
by andiso
hello,
is it possible to do a periodic timer interrupt that will occur for example every 1 msec or every 250 usec staff like that using the MOD5441x module?
and I want that this interrupt will operate a function that I will write that will turn a LED ON and OFF.
and if so which example from the examples is doing that?
thanks
Re: periodic timer interrupt
Posted: Thu Aug 09, 2018 9:58 am
by joepasquariello
See the project in the examples folder: nburn\examples\MOD5441X\MOD5441x-PIT-Timer
There are also ways to do this with no interrupts. You can use the PWM module or a DMA timer to produce a square wave at the desired frequency.
Joe
Re: periodic timer interrupt
Posted: Sun Aug 12, 2018 7:56 am
by andiso
yes but what I need is to do a "train" of pulses for example like this:
/```\_/```\_/```\_/``\_/``\_/`\_/`\______________/```\_/```\_/```\_/``\_/``\_/`\_/`\______________
in here you can see 3 pulses of 3msec then 2 pulses of 2msec and then 2 pulses of 1msec.
then after a delay of about 10msec the pattern repeat itself. 3 of 3msec 2 of 2 msec and 2 of 1 msec.
until now we did it with an interrupt and a statemachine code inside the interrupt function that did this. we used a different controller for this.
do you have a better way to perform this requierment?
anyway I took the code of the PIT and change it alittle bit lie this:
INTERRUPT( NbPit1_ISR, 0x2600 )
{
if(portflag==0)
portflag=1;
else
portflag=0;
J2[15] = portflag;
sim2.pit[1].pcsr = pit_pcsr_clr;
gPitCount[1]++;
if(pSem[1]) OSSemPost(pSem[1]);
if(pFlag[1]) OSFlagSet(pFlag[1],FlagV[1]);
}
I added this part:
if(portflag==0)
portflag=1;
else
portflag=0;
J2[15] = portflag;
but can I get a little explonation about this part:
sim2.pit[1].pcsr = pit_pcsr_clr;
gPitCount[1]++;
if(pSem[1]) OSSemPost(pSem[1]);
if(pFlag[1]) OSFlagSet(pFlag[1],FlagV[1]);
what is this code doing?
I noticed that if I remove this code then I cannot reburn the module and I need to do the shift 'A' procedure to fix it again...
Re: periodic timer interrupt
Posted: Sun Aug 12, 2018 10:32 am
by TomNB
Take a look at how interrupts are done with the HiResTimer example:
\nburn\examples\StandardStack\utils\HiResTimerDemo
That will let you do the same with a state machine as you did before.
Re: periodic timer interrupt
Posted: Mon Aug 13, 2018 8:21 pm
by pbreed
Is this to drive RC servos via a shift register?
If so I have that as working code, in my old code, I can look for it..
Can be done with a single DMA timer.
Re: periodic timer interrupt
Posted: Mon Aug 20, 2018 2:00 am
by andiso
no its not for RC servos...
its to create a specific pulse shape that we need for our medical system
thanks
Re: periodic timer interrupt
Posted: Sat Aug 25, 2018 5:05 am
by pbreed
Timer output compare via the dma timers is the best solution for this...