periodic timer interrupt

Discussion to talk about software related topics only.
Post Reply
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

periodic timer interrupt

Post 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
joepasquariello
Posts: 85
Joined: Mon Apr 28, 2008 7:32 am

Re: periodic timer interrupt

Post 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
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

Re: periodic timer interrupt

Post 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...
User avatar
TomNB
Posts: 569
Joined: Tue May 10, 2016 8:22 am

Re: periodic timer interrupt

Post 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.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: periodic timer interrupt

Post 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.
andiso
Posts: 16
Joined: Tue Jul 24, 2018 6:28 am

Re: periodic timer interrupt

Post by andiso »

no its not for RC servos...
its to create a specific pulse shape that we need for our medical system

thanks
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: periodic timer interrupt

Post by pbreed »

Timer output compare via the dma timers is the best solution for this...
Post Reply