PIT interrupt missed

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PIT interrupt missed

跳至解决方案
1,715 次查看
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?

标签 (1)
0 项奖励
回复
1 解答
1,603 次查看
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 项奖励
回复
3 回复数
1,603 次查看
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 项奖励
回复
1,603 次查看
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 项奖励
回复
1,604 次查看
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 项奖励
回复