赞
踩
- void RTC_Cfg(void)
-
- {
-
- stc_rtc_initstruct_t RtcInitStruct;
-
- RtcInitStruct.rtcAmpm = RtcPm; //12小时制
-
- RtcInitStruct.rtcClksrc = RtcClkRcl; //内部低速时钟
-
- RtcInitStruct.rtcPrdsel.rtcPrdsel = RtcPrds; //周期中断类型PRDS
-
- RtcInitStruct.rtcPrdsel.rtcPrds = Rtc1S; //周期中断事件间隔
-
- RtcInitStruct.rtcTime.u8Second = 0x55;
-
- RtcInitStruct.rtcTime.u8Minute = 0x01;
-
- RtcInitStruct.rtcTime.u8Hour = 0x10;
-
- RtcInitStruct.rtcTime.u8Day = 0x17;
-
- RtcInitStruct.rtcTime.u8DayOfWeek = 0x04;
-
- RtcInitStruct.rtcTime.u8Month = 0x04;
-
- RtcInitStruct.rtcTime.u8Year = 0x19;
-
- RtcInitStruct.rtcCompen = RtcCompenEnable;
-
- RtcInitStruct.rtcCompValue = 0;//补偿值根据实际情况进行补偿
-
- Rtc_Init(&RtcInitStruct);
-
- Rtc_AlmIeCmd(TRUE); //使能闹钟中断
-
- }
-

- void Rtc_IRQHandler(void)
-
- {
-
- if(Rtc_GetPridItStatus() == TRUE)
-
- {
-
- flag = 1;
-
- Rtc_ClearPrdfItStatus(); //清除中断标志位
-
- }
-
- }
-

- int32_t main(void)
-
- {
-
- int8_t i=0;
-
- stc_rtc_time_t readtime;
-
- Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE);//GPIO外设时钟打开
-
- Sysctrl_SetPeripheralGate(SysctrlPeripheralRtc,TRUE);//RTC模块时钟打开
-
- Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE);
-
- RTC_Cfg(); //配置RTC
-
- EnableNvic(RTC_IRQn, IrqLevel3, TRUE); //使能RTC中断向量
-
- Rtc_Cmd(TRUE);
-
- //使能RTC开始计数
-
- Sysctrl_ClkSourceEnable(SysctrlClkRCL,TRUE); ///< 使能RCL时钟
-
- Sysctrl_SetRCLTrim(SysctrlRclFreq32768); ///< 配置内部低速时钟频率为32.768kHz
-
- Sysctrl_SetPeripheralGate(SysctrlPeripheralLcd,TRUE); ///< 开启LCD时钟
-
- Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio,TRUE); ///< 开启GPIO时钟
-
- App_PortCfg(); ///< LCD端口配置
-
- App_LcdCfg(); ///< LCD模块配置
-
- Lcd_ClearDisp(); ///< 清屏
-
- Lcd_WriteRam(0,0x00000000); ///< 赋值寄存器LCDRAM0
-
- Lcd_WriteRam(1,0x00000000); ///< 赋值寄存器LCDRAM1
-
- while (1)
-
- {
-
- if(flag == 1)
-
- {
-
- flag = 0;
-
- Rtc_ReadDateTime(&readtime);
-
- second = readtime.u8Second;
-
- minute = readtime.u8Minute;
-
- hour = readtime.u8Hour;
-
- day = readtime.u8Day;
-
- week = readtime.u8DayOfWeek;
-
- month = readtime.u8Month;
-
- year = readtime.u8Year;
-
- s=((d[(minute&0x0f)]+0x08)<<16)+d[minute/16];
-
- Lcd_WriteRam(0,s);
-
- s=(d[(second&0x0f)]<<16)+d[second/16];
-
- Lcd_WriteRam(1,s);
-
- }
-
- }
-
- }
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。