KBI appropriate usage

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

KBI appropriate usage

3,476 次查看
admin
Specialist II
Hello,
 
I'd like to know if the KBI is appropriate for pulse detection (edge or level detection, pulse width calculations) use. If not, what are the limitations of the Keyboard Interrupt that doesn't allow this to be accomplished ?
 
 
 
Best Regards,
Roger Tannous.
标签 (1)
0 项奖励
回复
3 回复数

563 次查看
rhinoceroshead
Contributor I
For pulse width measurements, you need to have a free-running counter, so you would need to use the timer counter for a reference anyway.  I'm assuming there is a good reason that you would not be using the timer for the pulse width measurement, ie. it is already being used for something else.  The advantage to using the timer for pulse width measurements is that it latches the contents of the counter immediately when the predetermined condition exists.  The KBI can be made to latch the contents of the counter by software in the ISR, but there is a significant delay between the event and the latching of the counter since it takes the CPU time to stack the registers and begin handling the ISR.  If that delay is the same when the pulse goes high as it is when the pulse goes low, then you should still have an accurate measurement - but if you have any other interrupts configured, then you can not count on the delay being the same.  Suppose a timer interrupt occurs and the CPU starts stacking registers and then your KBI interrupt occurs.  The CPU will first have to handle the timer ISR before going to the KBI ISR.  The time the CPU spends working on the timer ISR becomes error in your measurement.  Even if you enable interrupts again immediately at the beginning of the timer ISR, there is a potential error coming from the time it takes the CPU to stack the registers for the timer ISR.
 
Also - some KBI modules can not be made sensitive to rising edges.  If the chip you are using is one of these then the best you could do is measure period and not pulse width.
 
I guess my question would be - why not use the input capture on the timer?  Are you out of channels?
0 项奖励
回复

563 次查看
admin
Specialist II

Hello,

I had an issue in the past, when i needed three IC inputs to detect the occurrence and the proper order of three signals derived from 3 AC phases. So I thought about the QY family where the KBI feature would be used. This is from where this idea came to my mind...

This happened before I had MR32 and GZ60 chips and I'm asking the question now because it came again to my mind while reading the HC08 Tutorial.

 

Best Regards,

Roger Tannous

0 项奖励
回复

563 次查看
peg
Senior Contributor IV

Hi Roger,

I will add a few points to rhinoheads,

The KBI interrupt is low priority, lower than the serial ones, which may be an issue for comms intensive applications.

If you are thinking of using the KBI because of all the pins it gives you, don't forget there is only one interrupt for all of them and it is up to you to work out which one tripped it (they are all just or'd together to generate the interrrupt) If you've got levels switching all over the place it is easy to get confused. This is not so much of a problem when your using it for a matrix keypad but limits the use of multiple KBI pins for other applications.

Regards David

 

0 项奖励
回复