init
This commit is contained in:
+156
@@ -0,0 +1,156 @@
|
||||
C51 COMPILER V9.51 RTC 09/21/2017 09:48:36 PAGE 1
|
||||
|
||||
|
||||
C51 COMPILER V9.51, COMPILATION OF MODULE RTC
|
||||
OBJECT MODULE PLACED IN .\hex\rtc.obj
|
||||
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Library\Sources\rtc.c ROM(COMPACT) OPTIMIZE(9,SIZE) BROWSE DEBUG OBJECTEXTE
|
||||
-ND PRINT(.\lst\rtc.lst) TABS(2) OBJECT(.\hex\rtc.obj)
|
||||
|
||||
line level source
|
||||
|
||||
1 #ifndef _RTC_C_
|
||||
2 #define _RTC_C_
|
||||
3 /*********************************************************************************************************
|
||||
-************/
|
||||
4 #include "ca51f_config.h"
|
||||
5 #if (IC_TYPE == IC_TYPE_CA51F2X)
|
||||
6 #include "includes\ca51f2sfr.h"
|
||||
*** WARNING C318 IN LINE 6 OF Library\Sources\rtc.c: can't open file 'includes\ca51f2sfr.h'
|
||||
7 #include "includes\ca51f2xsfr.h"
|
||||
*** WARNING C318 IN LINE 7 OF Library\Sources\rtc.c: can't open file 'includes\ca51f2xsfr.h'
|
||||
8 #include "includes\gpiodef_f2.h"
|
||||
*** WARNING C318 IN LINE 8 OF Library\Sources\rtc.c: can't open file 'includes\gpiodef_f2.h'
|
||||
9 #elif (IC_TYPE == IC_TYPE_CA51F3X)
|
||||
#include "includes\ca51f3sfr.h"
|
||||
#include "includes\ca51f3xsfr.h"
|
||||
#include "includes\gpiodef_f3.h"
|
||||
#endif
|
||||
14 #include "includes\system.h"
|
||||
15 #include "Library\includes\rtc.h"
|
||||
16 #include "Library\includes\delay.h"
|
||||
17 #include <intrins.h>
|
||||
18 /*********************************************************************************************************
|
||||
-************/
|
||||
19 /***********************************************************************************
|
||||
20 函数名: RTC_init
|
||||
21 功能说明: 初始化RTC控制寄存器
|
||||
22 输入参数: rtce RTC功能模块使能控制
|
||||
23 mse RTC毫秒中断使能控制
|
||||
24 hse RTC半秒中断使能控制
|
||||
25 返回值: 无
|
||||
26 ***********************************************************************************/
|
||||
-
|
||||
27 void RTC_init(RTCE_TypeDef rtce,MSE_TypeDef mse,HSE_TypeDef hse)
|
||||
28 {
|
||||
29 1 RTCON = (RTCON & 0x1F) | RTCE(rtce) | MSE(mse) | HSE(hse);
|
||||
*** ERROR C202 IN LINE 29 OF Library\Sources\rtc.c: 'RTCON': undefined identifier
|
||||
30 1 }
|
||||
31 #if 0
|
||||
/***********************************************************************************
|
||||
函数名: RTC_WriteSecond
|
||||
功能说明: RTC写入秒值
|
||||
输入参数: second 秒值
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_WriteSecond(unsigned char second) //second = 0~59
|
||||
{
|
||||
RTCON |= RTCWE(1);
|
||||
RTCS = second;
|
||||
Delay_50us(1);
|
||||
RTCON &= ~RTCWE(1);
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
函数名: RTC_WriteMinute
|
||||
C51 COMPILER V9.51 RTC 09/21/2017 09:48:36 PAGE 2
|
||||
|
||||
功能说明: RTC写入分值
|
||||
输入参数: minute 分值
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_WriteMinute(unsigned char minute) //minute = 0~59
|
||||
{
|
||||
RTCON |= RTCWE(1);
|
||||
RTCM = minute;
|
||||
Delay_50us(1);
|
||||
RTCON &= ~RTCWE(1);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
函数名: RTC_WriteHour
|
||||
功能说明: RTC写入小时
|
||||
输入参数: hour 小时值
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_WriteHour(unsigned char hour) //hour = 0~23
|
||||
{
|
||||
RTCON |= RTCWE(1);
|
||||
RTCH = (RTCH&0xE0)|hour;
|
||||
Delay_50us(1);
|
||||
RTCON &= ~RTCWE(1);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
函数名: RTC_WriteWeek
|
||||
功能说明: RTC写入星期
|
||||
输入参数: week 星期值
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_WriteWeek(unsigned char week) //hour = 1~7代表星期一~星期天
|
||||
{
|
||||
RTCON |= RTCWE(1);
|
||||
RTCH = (RTCH&0x1F)|(week<<5);
|
||||
Delay_50us(1);
|
||||
RTCON &= ~RTCWE(1);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
函数名: RTC_AlarmCfg
|
||||
功能说明: 配置RTC ALARM功能寄存器位
|
||||
输入参数: hce 小时比较使能控制
|
||||
mce 分钟比较使能控制
|
||||
sce 秒比较使能控制
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_AlarmCfg(HCE_TypeDef hce,MCE_TypeDef mce,SCE_TypeDef sce)
|
||||
{
|
||||
RTCON = (RTCON & 0xE3) | HCE(hce) | MCE(mce) | SCE(sce);
|
||||
}
|
||||
|
||||
/***********************************************************************************
|
||||
函数名: RTC_SetAlaramTime
|
||||
功能说明: 设置RTC ALARM时间
|
||||
输入参数: al_hr 闹钟小时值
|
||||
al_min 闹钟分钟值
|
||||
al_sec 闹钟秒值
|
||||
C51 COMPILER V9.51 RTC 09/21/2017 09:48:36 PAGE 3
|
||||
|
||||
返回值: 无
|
||||
***********************************************************************************/
|
||||
void RTC_SetAlaramTime(unsigned char al_hr,unsigned char al_min,unsigned char al_sec)
|
||||
{
|
||||
RTAH = al_hr;
|
||||
RTAM = al_min;
|
||||
RTAS = al_sec;
|
||||
}
|
||||
#endif
|
||||
119 /***********************************************************************************
|
||||
120 函数名: RTC_SetRTMSS
|
||||
121 功能说明: 设置毫秒中断间隔
|
||||
122 输入参数: rtmss
|
||||
123 返回值: 无
|
||||
124 ***********************************************************************************/
|
||||
125 void RTC_SetRTMSS(unsigned char rtmss)
|
||||
126 {
|
||||
127 1 RTMSS = rtmss;
|
||||
*** ERROR C202 IN LINE 127 OF Library\Sources\rtc.c: 'RTMSS': undefined identifier
|
||||
128 1 }
|
||||
129
|
||||
130 /*********************************************************************************************************
|
||||
-************/
|
||||
131 #endif
|
||||
|
||||
C51 COMPILATION COMPLETE. 3 WARNING(S), 2 ERROR(S)
|
||||
Reference in New Issue
Block a user