ch579 rtc使用時(shí)的問題
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í)行了?



您好,函數(shù)沒有往下執(zhí)行的原因是一直在頻繁的進(jìn)中斷導(dǎo)致,定時(shí)器觸發(fā)中斷默認(rèn)是打開的,

可以關(guān)閉定時(shí)器觸發(fā)中斷使能:RTC_ModeFunDisable(RTC_TRIG_MODE);

或在中斷中清除此中斷:RTC_ClearITFlag(RTC_TRIG_EVENT);


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频