需求: 因为需要用到低功耗方式,把4*4键盘的列线分别接入到P0.7 , P0.14 , P0.20 , P0.30上,正常工作时初始化GPIO,若系统没有任务时初始化为对应的外部中断EINT1 , EINT2 , EINT3,同时进入空闲状态,以降低系统功耗。
问题: 系统还没有进入到空闲状态时(已注释),仅仅执行了GPIO2EInt函数后,可以唤醒2148且键盘初始化为GPIO能正常工作,但此时U0串口发送不出数据,接受有时也不正常。
关键函数:
main() { do { Msg = GetMessage(EventPool); if(Msg.hProc > (CALLBACK)0x000001EC) { SysParam.Status &= (~SYS_STATUS_WAKE_UP) ; Msg.hProc(Msg.Data); SysParam.TimeOut = 0 ; } else { if(SysParam.TimeOut++ >= SYSTEM_IDLE_TIME / 40) { SysParam.Status |= SYS_STATUS_WAKE_UP ; Sleep(); } } }while(1); }
=====================================================================
void Sleep() { GPIO2EInt(); while(1) { if((SysParam.Status & SYS_STATUS_WAKE_UP) == SYS_STATUS_WAKE_UP) { KeyLightOff() ; LCDLightOff() ; // POWER->P_CON = 0x01 ; //idle status } else { SysParam.TimeOut = 0 ; KeyLightOn() ; LCDLightOn() ; //Menu.Status = MENU_STATUS_STAND_BY ; //ShowRdyStatu(NULL); break ; } } }
==================================================================
void WakeUp() { // POWER->P_CON = 0x00 ; PINSEL->PIN_SEL0 |= (P0_0_TXD0 << P0_0_PINSEL) | (P0_1_RXD0 << P0_1_PINSEL); //设置I/O连接到UART0 SYSCON->EXT_INT = 0x08 ; SYSCON->EXT_INT = 0x04 ; SYSCON->EXT_INT = 0x02 ;
PINSEL->PIN_SEL1 &= (P0_30_GPIO << P0_30_PINSEL); PINSEL->PIN_SEL1 &= (P0_20_GPIO << P0_20_PINSEL); PINSEL->PIN_SEL0 &= (P0_7_GPIO << P0_7_PINSEL) ; PINSEL->PIN_SEL0 &= (P0_14_GPIO << P0_14_PINSEL);
VIC->IntEnClr |= ( 1 << VICIntSel_EINT1 ) ; VIC->IntEnClr |= ( 1 << VICIntSel_EINT2 ) ; VIC->IntEnClr |= ( 1 << VICIntSel_EINT3 ) ; PLL->PLL_CON = 1 ; PLL->PLL_CFG = 0x25 ; // M = 6 P = 2 PLL->PLL_FEED = 0xAA ; PLL->PLL_FEED = 0x55 ; while(PLL->PLL_STAT & (1 << 10) == 0); PLL->PLL_CON = 3 ; PLL->PLL_FEED = 0xaa ; PLL->PLL_FEED = 0x55 ; KeyBoardInit(); SysParam.Status &= (~SYS_STATUS_WAKE_UP) ; VIC->IntEnable |= (1 << VICIntSel_PWM0) ; SysParam.TimeOut = 0 ; }
//-----------------------------------------------------------------------------------
void WakeUpFromEInt1() __irq { while((SYSCON->EXT_INT &0x02) != 0) { SYSCON->EXT_INT = ( 1 << EINT1 ) ; } WakeUp(); VIC->VectAddr = 0x00 ; }
//----------------------------------------------------------------------------------- void WakeUpFromEInt2() __irq { while((SYSCON->EXT_INT &0x04) != 0) { SYSCON->EXT_INT = ( 1 << EINT2 ) ; } WakeUp(); VIC->VectAddr = 0x00 ; }
//-----------------------------------------------------------------------------------
void WakeUpFromEInt3() __irq { while((SYSCON->EXT_INT &0x08) != 0) { SYSCON->EXT_INT = ( 1 << EINT3 ) ; } WakeUp(); VIC->VectAddr = 0x00 ; } //------------------------------------------------------------------------------------
void GPIO2EInt(void) { DisableIRQ(); PINSEL->PIN_SEL1 |= (P0_30_EINT3 << P0_30_PINSEL); PINSEL->PIN_SEL1 |= (P0_20_EINT3 << P0_20_PINSEL); PINSEL->PIN_SEL0 |= (P0_7_EINT2 << P0_7_PINSEL); PINSEL->PIN_SEL0 |= (P0_14_EINT1 << P0_14_PINSEL); VIC->IntEnClr |= ( 1 << VICIntSel_PWM0 ); P0->IODIR |= ( KEY_COL1 ) | ( KEY_COL2 ) | ( KEY_COL3 ) | ( KEY_COL4 ) ; P0->IOCLR |= ( KEY_COL1 ) | ( KEY_COL2 ) | ( KEY_COL3 ) | ( KEY_COL4 ) ; SYSCON->EXT_MODE = 0x00; //interrupt is low volate triggle SYSCON->EXT_POLAR = 0x00 ; SYSCON->INT_WAKE = ( 1 << EXTWAKE1 ) | ( 1 << EXTWAKE2 ) | ( 1 << EXTWAKE3 ) ; SYSCON->EXT_INT = ( 1 << EINT1 ) | ( 1 << EINT2) | ( 1 << EINT3 ) ; VIC->VectCntls[5] = VICIntSel_Enable | VICIntSel_EINT1 ; VIC->VectAddrs[5] = (unsigned int)WakeUpFromEInt1; //
VIC->VectCntls[6] = VICIntSel_Enable | VICIntSel_EINT2 ; VIC->VectAddrs[6] = (unsigned int)WakeUpFromEInt2 ; //
VIC->VectCntls[7] = VICIntSel_Enable | VICIntSel_EINT3 ; VIC->VectAddrs[7] = (unsigned int)WakeUpFromEInt3 ; //
VIC->IntEnable |= ( 1 << VICIntSel_EINT1 ) | ( 1 << VICIntSel_EINT2 ) | ( 1 << VICIntSel_EINT3 ); EnableIRQ(); }
|