KBI and Port I/O

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

KBI and Port I/O

1,210 次查看
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
标签 (1)
0 项奖励
回复
1 回复

708 次查看
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 项奖励
回复