Question on RS08 keyboard interrupt

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

Question on RS08 keyboard interrupt

Jump to solution
1,282 Views
Kopone
Contributor IV

Hello,

 

I checked the MC9RS08KA2.pdf but am still not sure about two things:

 

1. When I configure multiple pins as a keyboard interrupt source, how am I supposed to find out which pin did actually cause the interrupt?

From how I got it, I need to poll SIP1_KBI (same for all pins) to find out about an interrupt at all.

What is the recommended best practice after that, just read the value of the port bits, like this:

 

if(PTAD_PTAD0) // Key 0 pressed

...

if(PTAD_PTAD1) // Key 1 pressed

 

or is there  a different method?

 

2. How do I reset the interrupt flag to allow for successive interrupts?

 

Chapter 5.8.6 says (about the SIP1_KBI bit):

"Clearing the KBF flag of the KBISC register clears this bit."

 

Chapter 7.3.1 however states:

"Writes have no effect on KBF." So I assume "KBISC_KBF = 0;" won't work.

 

Then I find:

"Writing a 1 to KBACK is part of the flag-clearing mechanism."

 

This sounds like it would take several steps to really clear the flag, however I can't seem to find a more detailed description of the mentioned "flag-clearing mechanism."

 

So is "KBISC_KBACK = 1;" all there is to do? According to the block diagram this seems fine, but the above quote is somewhat confusing to me.

 

Regards,

 Sven

Labels (1)
0 Kudos
1 Solution
318 Views
peg
Senior Contributor IV

Hi Sven,

 

Firstly, I have no experience with the RS08. These comments are based on S08.

 

You have to work out which of the enabled KBI pins caused the interrupt yourself.

Normally you would read the whole port into a variable first and analyse it from there. This avoids the time skew of polling each one individually.

 

You can poll the flag to find out if a KBI enabled pin has been activated, or you can enable interrupts to interrupt when the flag becomes set.

 

Writing a 1 to KBACK is all that is required to clear the flag and acknowledge the interrupt.

 

Hope that helps.

 

View solution in original post

0 Kudos
2 Replies
319 Views
peg
Senior Contributor IV

Hi Sven,

 

Firstly, I have no experience with the RS08. These comments are based on S08.

 

You have to work out which of the enabled KBI pins caused the interrupt yourself.

Normally you would read the whole port into a variable first and analyse it from there. This avoids the time skew of polling each one individually.

 

You can poll the flag to find out if a KBI enabled pin has been activated, or you can enable interrupts to interrupt when the flag becomes set.

 

Writing a 1 to KBACK is all that is required to clear the flag and acknowledge the interrupt.

 

Hope that helps.

 

0 Kudos
318 Views
Kopone
Contributor IV

Thank you very much for the quick reply. Exactly what I needed to know :smileyhappy:

 


peg wrote:

 

You can poll the flag to find out if a KBI enabled pin has been activated, or you can enable interrupts to interrupt when the flag becomes set.

 


 

On a RS08 this seems to result in the (more or less) same code, since it has no interrupt vector table. From how I got it, an interrupt on the RS08 will not really interrupt code execution (to jump anywhere else). Instead, the only thing an interrupt can do is wake the MCU from WAIT and STOP modes (and set the according flag in SIP1). So if you don't use any wait modes, there seems no way arround polling (be it SIP1 or the IO ports directly).

 

Regards,

 Sven

0 Kudos