// 初始化部分 // Pin change interrupt // PCINT20 enabled, other PCINTs disabled PCIFR = 0x0f; // clear all pin change interrupt flags PCICR = (1<<PCIE2); // PCINT23:16 enabled PCMSK3 = 0; PCMSK2 = (1<<PCINT20); // PCINT20 enabled PCMSK1 = 0; PCMSK0 = 0; ... sei(); // enable interrupts globally ...
// 中断服务程序 #pragma vector=PCINT2_vect __interrupt void irqPCInt2(void) { // PCIF2 bit in the PCIFR register is automatically cleared when interrupt service routine is executed static BOOL bDebug; if(bDebug){ DEBUG_LO; bDebug = 0; }else{ DEBUG_HI; bDebug = 1; } } |