Interrupt attention

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt attention

2,214 Views
Cram
Contributor III
Hi all, I'm newbie this is my third project with freescale CPUs, I'm using the 908QG8. I need to count and external tune burst (ultra very low frequency), I use the MTIM in a free-running mode during the sample time and it works perfect (currently working), but now I want to add a simple protection: manage the MTIMCNT overflow, I know how to manage the interrupt but when I finish to attempt the routine I don't want to follow with the next instruction, I just want to reset the MTIMCNT and star again the sample period. In the interrupt routine for the MTIM Can I reset the overflow flag (MTIM:TOF), stop the MTIM, Reset the counter and then call the sample function? Is that correct? Thxs for all
Labels (1)
0 Kudos
Reply
4 Replies

1,065 Views
Cram
Contributor III
Hi Peg, thanks for your answer. Let me explain a little bit more. As I understand in the datasheet when the MTIM is in free-running MODULO value will not reset the MTIMCNT because MODULO equals the $00. I'm trying to avoid some EMC issue, I'm reading a very low freq (more or less 60Hz, falling edge) so any radiated EMC will overflow the MTIM. What I need is to created a "dead time". When the MTIM overflow I need to attend the interrupt and then sample some freq. to check if I'm receiving an EMC or the real data. So it's better to back again to the main loop and deal with the EMC there than jump directly from the interrupt routine to a special function. thanks for all.
0 Kudos
Reply

1,065 Views
peg
Senior Contributor IV
Hi Cram,

It sounds like you are using the MTIM more as a counter by feeding your pulses to TCLK. Is this right?
Still I think my points are valid. Do you really need an interrupt or just check TOF when you would check the count at the end of sample period, if it is set you got noise, give up, clear it and try again.

0 Kudos
Reply

1,065 Views
Cram
Contributor III
Hi Peg,

Yes that's true I'm feeding the TCLK, and running the MTIM as a counter.

I activated the Interrupt for the MTIM because I'm just polling another pin, and I follow your notes and manage the interrupt just to acknowledge the interrupt and in the main loop (re-sampling until the EMC issue dissapears), and it seems to work better than my first solution.

thanks for all!
0 Kudos
Reply

1,065 Views
peg
Senior Contributor IV
Hello and welcome to the forums Cram,

It is not clear exactly what you are trying to achieve here.

At the point that the overflow isr would occur the MTIM is already reset by itself reaching the modulo the counter is set to.

As for trying to jump out of the middle of an ISR to somewhere else, this is definately a no-no. You should mark that something occurred and then fall back to the normal programme flow where you would act appropriately considering that this event has occurred.

It would seem that as you are not really going to achieve anything within the ISR here (as MTIM already reset) that simply polling MTIM:TOF might be the best solution.

Or maybe I have missunderstood what it is you are trying to achieve.

0 Kudos
Reply