int main()
{
PWR_DCDCCfg(ENABLE);
uint8_t i;
SetSysClock(CLK_SOURCE_PLL_60MHz);
GPIOA_ModeCfg( GPIO_Pin_All, GPIO_ModeIN_PU );
GPIOB_ModeCfg( GPIO_Pin_All, GPIO_ModeIN_PD );
WS2812x_Power_Set(ENABLE);
Key_init();
/* 配置串口调试 */
DebugInit();
PRINT("Start @ChipID=%02X\n", R8_CHIP_ID);
PRINT( "Time=%s-%s\n",__TIME__,__DATE__ );
SysTick_Config(GetSysClock() / 1000 * SYSTICK_INTERVAL);
SysTick->SR = 0; //清除中断标志
PFIC_DisableIRQ(SysTick_IRQn);
RTC_Init();
WX281X_Init();
while(1)
{
if(SysTick->SR)
{
SysTick->SR = 0;
KeyValue = key_read();
if(KEY_Event_Click == KeyValue)
{
PlayMode++;
if(PlayMode == 5)PlayMode = 1 ;
switch(PlayMode)
{
case 2 :Function_state_1 = 0 ;PlayFunction_1();break ;
case 1 :Function_state_4 = 0 ;PlayFunction_4(0,64,8);break ;
case 3 :Function_state_3 = 0 ;PlayFunction_3(&StrBuff[0],0,0,80);break ;
case 4 :Function_state_4 = 0 ;PlayFunction_4(0,64,8);break ;
}
}
else if(KEY_Event_Press == KeyValue)
{
ARGB_FillRGB(0, 0, 0);
PRINT( "sleep mode sleep \n" );
DelayMs( 10 );
WS2812x_Power_Set(DISABLE);
while(!GPIOB_ReadPortPin(GPIO_Pin_0));
LowPower_Sleep(RB_PWR_RAM30K | RB_PWR_RAM2K); //只保留30+2K SRAM 供电
//LowPower_Halt();
HSECFG_Current( HSE_RCur_100 ); // 降为额定电流(低功耗函数中提升了HSE偏置电流)
DelayMs( 5 );
WS2812x_Power_Set(ENABLE);
PRINT( "wake.. \n" );
DelayMs( 500 );
}
Usart_scan();
switch(PlayMode)
{
case 2 :PlayFunction_1();break ;
case 1 :PlayFunction_4(0,64,8);break ;
case 3 :PlayFunction_3(&StrBuff[0],0,0,80);break ;
case 4 :PlayFunction_4(0,64,8);break ;
}
}
}
}
问题点:
1、项目没有使用协议栈,有RTC 时钟,16秒唤醒一次。当连接串口后,RTC时钟不能定时触发,断开串口后可以
2、程序使用了systick时钟,唤醒后工作不正常,SPI 一直输出高电平,轮询的按键功能也不能工作。是因为主时钟有问题?感觉程序没有跑起来
3、while(!GPIOB_ReadPortPin(GPIO_Pin_0));是为了进睡眠前确认按键已经松开。不加这一句的,睡眠电流大不少,但唤醒后工作是正常的
请工程师帮我看一下啊,想了好久都没有找到原因