大家好,最近在调试KL16的低功耗,采用的VLPS模式,利用UART0唤醒。现在的情况是串口采用FLL的时钟,利用串口的边沿唤醒功能,在进入低功耗以后串口不工作,当RX检测到电平变化以后进入串口中断唤醒单片机,
目前的低功耗电流约为3uA,现在遇到的问题是单片机只能被唤醒一次,第二次软件进入低功耗以后就不能被唤醒了,必须复位才可以。有没有大神能帮忙分析分析?
假如不进入低功耗的话串口工作正常,附件是工程,谢谢给位了!
int main (void)
{
SystemCoreClockUpdate();
PORT_ENABLE_CLK(MKL_PORTA);
uart0Init(9600,0,0,8,1); /* UART0初始化 */
printf("\n\r test \r\n");
while(1){
myDelay(1000);
uart0Init(9600,0,0,8,1);
clockMonitor(0);
printf("\n\r enter VLPS mode \r\n");
EnterVLPS();
clockMonitor(1);
};
}
void uart0Init (INT32U ulBaudRate,
INT8U ucParityEnable,
INT8U ucParityType,
INT8U ucDataLength,
INT8U ucStopBit)
{
SIM_SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK;
SIM_SOPT2 |= SIM_SOPT2_UART0SRC(1); /* FLL时钟源 */
SIM_SCGC4 |= SIM_SCGC4_UART0_MASK; /* 使能时钟 */
PORTA_PCR1 = PORT_PCR_MUX(0x2); /* UART0_TXD */
PORTA_PCR2 = PORT_PCR_MUX(0x2); /* UART0_RXD */
PORTA_PCR1 |=PORT_PCR_PE_MASK;
PORTA_PCR1 |=PORT_PCR_PS_MASK;
UART0_C2 &= ~ (UART0_C2_TE_MASK| UART0_C2_RE_MASK); //关闭收发
NVIC_EnableIRQ(UART0_IRQn);
NVIC_SetPriority(UART0_IRQn,3);
UART0_BDH = 0x00;
UART0_BDH |= UART0_BDH_RXEDGIE_MASK; //边沿唤醒 RXEDGIF
UART0_BDL = 0x9C;
UART0_C4 = 0x0F;
// UART0_C1 = UART0_C1_WAKE_MASK;
UART0_C1=0;
UART0_C3 = 0x00;
UART0_MA1 = 0x00;
UART0_MA1 = 0x00;
UART0_C2 = UART0_C2_RIE_MASK; //使能接收
UART0_S1 |= 0x1F;
UART0_S2 |= 0xC0;
UART0_C2 |= UART0_C2_TE_MASK| UART0_C2_RE_MASK; //开启收发
}
void UART0_IRQHandler (void)
{
UART0_MemMapPtr uartPtr = UART0_BASE_PTR; /* 发送中断处理程序 */
while (UART0_S1_REG(uartPtr) & UART0_S1_RDRF_MASK)
{
uart0SendChar(UART0_D_REG(uartPtr));
}
UART0_BDH &= ~UART0_BDH_RXEDGIE_MASK; ////关闭边沿唤醒 否则一直进入中断
}
KL16-VLPS-UART0-WAKE UP.zip
(812.64 KB)
|