PIT interrupt missed

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

PIT interrupt missed

Jump to solution
802 Views
larryo
Contributor II

On a KL05.. using PE, I set up an interrupt from a PIT. Within the ISR I toggle a port bit just to check the functionality. I find that the port bit does not change on every expected tic of the PIT. The timing is correct except that a state change is missed once in awhile. For example if I set the PIT to 1ms, sometimes there will be a 2, 3 or 4 ms interval instead of the expected 1ms. I can change the source to other timers and it makes no difference. I can also change the timer interval from 1ms to 100ms and it still will miss once in awhile.

The miss rate has to do with other code that is running. If I only have a while(1) loop it's fine. If I add almost anything within the while loop it will start to miss.

 

Originally I had a number of print statements and this seemed to make matters much worse. However even when I comment out almost the entire contents of the while loop it will still happen on occasion.

 

It seems like something else is messing with the timer or disabling the interrupts. Also, changing the priority has no effect. As far as I know, no other interrupts are enabled.

 

I'm stuck. Anyone have any ideas?

Labels (1)
0 Kudos
1 Solution
690 Views
larryo
Contributor II

OOPS,

I had an issue with the declaration of a variable used in the isr. The net result was it was apparently getting stepped on elsewhere.

So, no problem

View solution in original post

0 Kudos
3 Replies
690 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Larry,

How do you measure it ?

And in the interrupt function , do you only toggle the LED ?

If there is no other interrupt , also the time of interrupt function is less than

1ms , i think there should be not error .

Also you can send your project to me , i check it on my side .

Hope it helps

Alice

0 Kudos
690 Views
larryo
Contributor II

Hi Alice,

Thanks for the quick reply.

I have an Oscilloscope connected to the port bit. The scope has a handy trigger function of trigger if > n. With a 1ms PIT, I set the trigger to > 1.1ms and see a period that is actually a multiple of 1ms once in awhile.

The only thing in the isr is the toggle LED. I do use PE macros for the I/O bit control.

With almost nothing going on in the main loop, the period of the > 1.1ms event is periodic at around 1 second. There is a software counter in the main loop with a period of about 1 second also. This is all within a while(1) loop. Curious coincidence?

I originally had some A/D reads, print statements and some floating point in the while loop. In this condition the PIT "misses" were quite often. I incrementally commented out code in the while(1) and the miss incidence went down.

If I comment out the entire contents of the while loop except one function call the issue goes away. I suppose that at some point the compiler is optimizing out the entire while loop but I have not dug into this aspect of the question.

I did just realize that I am actually using CW 10.6 and not KDS so I'm thinking this might be an issue in sending you the project or even having posted the question here?

Regards

Larry

0 Kudos
691 Views
larryo
Contributor II

OOPS,

I had an issue with the declaration of a variable used in the isr. The net result was it was apparently getting stepped on elsewhere.

So, no problem

0 Kudos