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); }
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
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