CH579 上电后 LSE 默认开启, 作为GPIO 使用前,需要将LSE 功能关闭:
可以参考下面函数(路径CH579 EVT_2.4>EXAM>BLE>HAL>RTC.c 中 ),
当CLK_OSC32K 非0 时候,关闭LSE ,开启LSI, rtc时钟源设置为LSI
void HAL_TimeInit( void ) {
#if( CLK_OSC32K )
R8_SAFE_ACCESS_SIG = 0x57;
R8_SAFE_ACCESS_SIG = 0xa8;
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT|RB_CLK_XT32K_PON);
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
R8_SAFE_ACCESS_SIG = 0;
Calibration_LSI();
#else
R8_SAFE_ACCESS_SIG = 0x57;
R8_SAFE_ACCESS_SIG = 0xa8;
R8_CK32K_CONFIG |= RB_CLK_OSC32K_XT | RB_CLK_INT32K_PON | RB_CLK_XT32K_PON;
R8_SAFE_ACCESS_SIG = 0;
#endif
RTC_InitTime( 2020, 1, 1, 0, 0, 0 ); //RTC时钟初始化当前时间
TMOS_TimerInit( 0 );
}
CH579 上电后 LSE 默认开启, 作为GPIO 使用前,需要将LSE 功能关闭:
可以参考下面函数(路径CH579 EVT_2.4>EXAM>BLE>HAL>RTC.c 中 ),
当CLK_OSC32K 非0 时候,关闭LSE ,开启LSI, rtc时钟源设置为LSI
void HAL_TimeInit( void ) {
#if( CLK_OSC32K )
R8_SAFE_ACCESS_SIG = 0x57;
R8_SAFE_ACCESS_SIG = 0xa8;
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT|RB_CLK_XT32K_PON);
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
R8_SAFE_ACCESS_SIG = 0;
Calibration_LSI();
#else
R8_SAFE_ACCESS_SIG = 0x57;
R8_SAFE_ACCESS_SIG = 0xa8;
R8_CK32K_CONFIG |= RB_CLK_OSC32K_XT | RB_CLK_INT32K_PON | RB_CLK_XT32K_PON;
R8_SAFE_ACCESS_SIG = 0;
#endif
RTC_InitTime( 2020, 1, 1, 0, 0, 0 ); //RTC时钟初始化当前时间
TMOS_TimerInit( 0 );
}
举报