int?main(void) { ???? uint8_t?i; SystemClock_UART1_init();? sys_rtc_init(2023,6,2,12,0,0);???///?調(diào)用這一句后?下面的不執(zhí)行 printf("begin?run?version?20230510\n");
void?sys_rtc_init(UINT16?y,?UINT16?mon,?UINT16?d,?UINT16?h,?UINT16?m,?UINT16?s) { ///?//使用內(nèi)部的32K?RC作為RTC的時(shí)鐘,由于rc振蕩器是誤差比較大,所以wch提供了校準(zhǔn)函數(shù),并且根據(jù)需求是校準(zhǔn)到32Khz?還是32.768khz #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(?y,?mon,?d,?h,?m,?s?);????//RTC時(shí)鐘初始化當(dāng)前時(shí)間 RTC_TMRFunCfg(Period_1_S); NVIC_EnableIRQ(RTC_IRQn); } ? __attribute__((interrupt("WCH-Interrupt-fast")))????????????????//?wch的硬件壓棧 __attribute__((section(".highcode")))???????????????????????????//?需要放到RAM里面 void?RTC_IRQHandler(?void?) { ????????UINT16?py;?UINT16?pmon;UINT16?pd;UINT16?ph;UINT16?pm;UINT16?ps; if(RTC_GetITFlag(RTC_TMR_EVENT)){ RTC_GetTime(&py,&pmon,&pd,&ph,&pm,&ps); printf("%04d-%02d-%02d?%02d:%02d:%02d\r\n",py,pmon,pd,ph,pm,ps);??//這里每秒正常打印 RTC_ClearITFlag(RTC_TMR_EVENT); } }
main 函數(shù)里調(diào)用 sys_rtc_init 后就不往下執(zhí)行了?
熱門產(chǎn)品 :
CH339: 7端口多功能USB HUB控制器芯片