C51 COMPILER V9.02   MAIN                                                                  12/12/2025 16:44:57 PAGE 1   


C51 COMPILER V9.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\output\main.obj
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE source\main.c OMF2 BROWSE DEBUG PRINT(.\lst\main.lst) OBJECT(.\output\main.
                    -obj)

line level    source

   1          
   2          #ifndef _MAIN_C_
   3          #define _MAIN_C_
   4          /*********************************************************************************************************
             -************/
   5          #include "include/ca51f_config.h"               
   6          #include "include/ca51f2sfr.h"
   7          #include "include/ca51f2xsfr.h"
   8          #include "include/gpiodef_f2.h"
   9          #include "include/system_clock.h"
  10          
  11          #include "include/uart.h"
  12          #include "include/delay.h"
  13          #include "include/rtc.h"
  14          #include <intrins.h>
  15          /*********************************************************************************************************
             -************/
  16          
  17          /*********************************************************************************************************
             -************
  18                  RTC控制例程
  19          **********************************************************************************************************
             -***********/
  20          bit HalfSecFlag;
  21          bit AlarmEvFlag;
  22          void RTC_ISR (void) interrupt 13         
  23          {
  24   1              if(RTCIF & RTC_MF)                      //毫秒中断
  25   1              {
  26   2                      RTCIF = RTC_MF;                 
  27   2              }
  28   1              if(RTCIF & RTC_HF)                      //半秒中断
  29   1              {
  30   2                      RTCIF = RTC_HF;
  31   2                      HalfSecFlag = 1;
  32   2              }       
  33   1              if(RTCIF & RTC_AF)                      //闹钟中断
  34   1              {
  35   2                      RTCIF = RTC_AF; 
  36   2                      AlarmEvFlag = 1;
  37   2              }
  38   1      }                                                               
  39          void main(void)
  40          {
  41   1      #ifdef LVD_RST_ENABLE
  42   1              LVDCON = 0xE1;                                  //设置LVD复位电压为2V
  43   1      #endif
  44   1              
  45   1      #if (SYSCLK_SRC == PLL)
                      Sys_Clk_Set_PLL(PLL_Multiple);  //设置系统时钟为PLL，PLL_Multiple为倍频倍数
              #endif
  48   1              
  49   1      #ifdef UART0_EN
                      Uart0_Initial(UART0_BAUTRATE);  //初始化UART0
C51 COMPILER V9.02   MAIN                                                                  12/12/2025 16:44:57 PAGE 2   

              #endif
  52   1              
  53   1      #ifdef UART1_EN
                      Uart1_Initial(UART1_BAUTRATE);  //初始化UART1
              #endif
  56   1      
  57   1      #ifdef UART2_EN
                      Uart2_Initial(UART2_BAUTRATE);  //初始化UART2
              #endif
  60   1              
  61   1              EA = 1;                                                                                                 //开全局中断
  62   1      
  63   1      #ifdef PRINT_EN
                      uart_printf("RTC Demo Code\n");
              #endif
  66   1      
  67   1              P72F = P72_XOSCL_IN_SETTING;                    //设置P72为晶振引脚
  68   1              P71F = P71_XOSCL_OUT_SETTING;                   //设置P71为晶振引脚
  69   1              CKCON |= XLCKE;                                                 //使能XSOCL
  70   1              while(!(CKCON & XLSTA));                                //等待XSOCL稳定
  71   1              
  72   1              RTCON = RTCE(1) | MSE(1) | HSE(1) | SCE(1) | MCE(1) | HCE(1);   //使能RTC功能，设置半秒、毫秒中断开启，闹铃
             -功能开启(时、分、秒匹配使能)
  73   1              
  74   1              Delay_50us(6);          //RTC使能后必须延时300us再写入时间， 否则写入时间可能无效。
  75   1              
  76   1              //设置当前时间为12:00:00
  77   1              RTC_WriteHour(12);                      
  78   1              RTC_WriteMinute(0);             
  79   1              RTC_WriteSecond(0);                     
  80   1      
  81   1              //设置闹钟时间为12:01:00
  82   1              RTAH    =       12;                     
  83   1              RTAM    =       1;
  84   1              RTAS    =       0;
  85   1              
  86   1              RTMSS = 0;                      //设置毫秒中断时间间隔
  87   1              INT8EN = 1;                     //RTC中断使能
  88   1              
  89   1              HalfSecFlag = 0;
  90   1              AlarmEvFlag = 0;
  91   1              
  92   1              while(1)
  93   1              {
  94   2                      if(HalfSecFlag) //半秒打印当前时间
  95   2                      {
  96   3                              HalfSecFlag = 0;
  97   3      #ifdef PRINT_EN
                                      uart_printf("Hour = %d,Minute = %d,Second = %d\n",(unsigned int)(RTCH&0x1F),(unsigned int)RTCM,(unsigne
             -d int)RTCS);        
              #endif          
 100   3                      }
 101   2                      if(AlarmEvFlag) //闹钟中断产生时打印
 102   2                      {
 103   3                              AlarmEvFlag = 0;
 104   3      #ifdef PRINT_EN
                                      uart_printf("Alarm event happen!\n");   
              #endif          
 107   3                      }
 108   2              }
 109   1      
 110   1      }
C51 COMPILER V9.02   MAIN                                                                  12/12/2025 16:44:57 PAGE 3   

 111          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    119    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      2    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
