KBI and Port I/O

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

KBI and Port I/O

1,203 Views
leofab70
Contributor I

Hello everybody 

 

I'am scripting a MC9S08SE8CLR and I found my self in trouble with this:

 

I already have the KBI working properlly but I want to USE A PTA ping to control a display, so I can display a huendred counter. The question is, Can I use the KBI and the the PTA in pin at the same time ???, and how would you do it??

 

Another thing is that I make the KBI in one variable like this 

 

 

if (--KBI_Debounce == 0){
             KBI_ProcessKey =0;
             auxptb=PTBD;
             ProccesKey((PTAD|0b11110000) & ((auxptb<<4)|0b00111111)); // de esta forma los puertos A&B queden en una sola variable 
             InitKBI(KBISC|0b11001111);
          }

 

if (--KBI_Debounce == 0){             KBI_ProcessKey =0;             auxptb=PTBD;             ProccesKey((PTAD|0b11110000) & ((auxptb<<4)|0b00111111)); // de esta forma los puertos A&B queden en una sola variable              InitKBI(KBISC|0b11001111);          }

 

 

void InitKBI(byte KBIpin) { 

  KBISC_KBIE=0;

  KBIPE = KBIpin;       //enable KBI pin

  KBISC = KBISC_KBIE_MASK|KBISC_KBACK_MASK;         //enable KBI int and clear KBF

} //end InitKBI

Many Thanks 
I really appreciate examples about it 
Leo Sandoval
Labels (1)
0 Kudos
Reply
1 Reply

701 Views
bigmac
Specialist III

Hello Leo, and welcome to the forum.

 

I presume that you would use one of the PTA4-PTA7 pins that are not associated with the KBI use.  These pins can continue to be used as GPIO in the normal manner, as can any of the KBI pins that are not enabled for KBI use, such as PTB0 and PTB1.

 

I notice that the datasheet recommends to clear the flag, and then to enable KBI interrupts, as two separate operations. 
This is to guarantee that the flag will be clear when interrupts are enabled.

 

 void InitKBI( byte KBIpin) {     KBISC_KBIE = 0;    KBIPE = KBIpin;           // enable KBI pins    KBISC = KBISC_KBACK_MASK; // Clear KBF flag    KBISC = KBISC_KBIE_MASK;  // Enable KBI interrupts }

Regards,

Mac

 

0 Kudos
Reply