二、修改部分 我这里使用了完全下电模式,达到最小的电流,对应配置如下: 使用 CH573EVT_1.6\EVT\EXAM\PM里面的几个函数,注意下面会掉电,重启了 PRINT( "shut down mode sleep \r\n" ); PWR_PeriphWakeUpCfg( ENABLE, RB_SLP_GPIO_WAKE, Edge_ShortDelay ); DelayMs( 2 ); LowPower_Shutdown( 0 ); //全部断电,唤醒后复位 /* 此模式唤醒后会执行复位,所以下面代码不会运行, 注意要确保系统睡下去再唤醒才是唤醒复位,否则有可能变成IDLE等级唤醒 */ HSECFG_Current( HSE_RCur_100 ); // 降为额定电流(低功耗函数中提升了HSE偏置电流) PRINT( "wake.. \n" ); DelayMs( 500 );
使用上面的配置后,大概能到1ua左右,其实这里还跑着RTC,我们要自己关掉RTC - 我这里使用的是内部的RTC,所以关闭内部RC即可
修改LowPower_Shutdown函数,增加内部RTC的关闭
//RTC也关掉!
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
R8_CK32K_CONFIG &= ~ RB_CLK_INT32K_PON;
整个函数
void LowPower_Shutdown( UINT8 rm )
{
UINT8 x32Kpw, x32Mpw;
x32Kpw = R8_XT32K_TUNE;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw&0xfc)|0x03; // 150%额定电流
if(R16_RTC_CNT_32K>0x3fff){ // 超过500ms
x32Kpw = (x32Kpw&0xfc)|0x01; // LSE驱动电流降低到额定电流
}
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
R8_BAT_DET_CTRL = 0; // 关闭电压监控
R8_XT32K_TUNE = x32Kpw;
R8_XT32M_TUNE = x32Mpw;
R8_SAFE_ACCESS_SIG = 0;
SetSysClock( CLK_SOURCE_HSE_6_4MHz );
PFIC -> SCTLR |= (1<<2); //deep sleep
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
R8_SLP_POWER_CTRL |= RB_RAM_RET_LV;
R16_POWER_PLAN = RB_PWR_PLAN_EN \
|RB_PWR_MUST_0010 \
|rm;
//RTC也关掉!
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;
R8_CK32K_CONFIG &= ~ RB_CLK_INT32K_PON;
__WFI();
__nop();__nop();
}
|