⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.txt

📁 STM32的RTC例程
💻 TXT
📖 第 1 页 / 共 3 页
字号:
                  |L1.762|
;;;169        {
;;;170        }
;;;171      }
;;;172    
;;;173      /* Enable USART1, GPIOA and GPIOC clocks */
;;;174      RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | 
0002fa  2101              MOVS     r1,#1
0002fc  f2440014          MOV      r0,#0x4014
000300  f7fffffe          BL       RCC_APB2PeriphClockCmd
;;;175                             RCC_APB2Periph_GPIOC , ENABLE);
;;;176    }
000304  bd10              POP      {r4,pc}
;;;177    
                          ENDP

                  main PROC
;;;54     int main(void)
;;;55     {
000306  b510              PUSH     {r4,lr}
;;;56     #ifdef DEBUG
;;;57       debug();
;;;58     #endif
;;;59     
;;;60       /* System Clocks Configuration */
;;;61       RCC_Configuration();
000308  f7fffffe          BL       RCC_Configuration
;;;62      
;;;63       /* NVIC configuration */
;;;64       NVIC_Configuration();
00030c  f7fffffe          BL       NVIC_Configuration
;;;65     
;;;66       /* Configure the GPIOs */
;;;67       GPIO_Configuration();
000310  f7fffffe          BL       GPIO_Configuration
;;;68       
;;;69       /* Configure the USART1 */
;;;70       USART_Configuration();
000314  f7fffffe          BL       USART_Configuration
;;;71          
;;;72       if(BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
000318  2004              MOVS     r0,#4
00031a  f7fffffe          BL       BKP_ReadBackupRegister
00031e  f5a04125          SUB      r1,r0,#0xa500
000322  39a5              SUBS     r1,r1,#0xa5
000324  d00f              BEQ      |L1.838|
;;;73       {
;;;74         /* Backup data register value is not correct or not yet programmed (when
;;;75            the first time the program is executed) */
;;;76     
;;;77         printf("\r\n\n RTC not yet configured....");
000326  a058              ADR      r0,|L1.1160|
000328  f7fffffe          BL       __1printf
;;;78        
;;;79         /* RTC Configuration */
;;;80         RTC_Configuration();
00032c  f7fffffe          BL       RTC_Configuration
;;;81     
;;;82          printf("\r\n RTC configured....");
000330  a05d              ADR      r0,|L1.1192|
000332  f7fffffe          BL       __1printf
;;;83      
;;;84         /* Adjust time by values entred by the user on the hyperterminal */
;;;85         Time_Adjust();
000336  f7fffffe          BL       Time_Adjust
;;;86     
;;;87         BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);    
00033a  f24a51a5          MOV      r1,#0xa5a5
00033e  2004              MOVS     r0,#4
000340  f7fffffe          BL       BKP_WriteBackupRegister
000344  e019              B        |L1.890|
                  |L1.838|
;;;88       }
;;;89       else
;;;90       {
;;;91         /* Check if the Power On Reset flag is set */
;;;92         if(RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
000346  207b              MOVS     r0,#0x7b
000348  f7fffffe          BL       RCC_GetFlagStatus
00034c  b118              CBZ      r0,|L1.854|
;;;93         {
;;;94           printf("\r\n\n Power On Reset occurred....");
00034e  a05c              ADR      r0,|L1.1216|
000350  f7fffffe          BL       __1printf
000354  e006              B        |L1.868|
                  |L1.854|
;;;95         }
;;;96         /* Check if the Pin Reset flag is set */
;;;97         else if(RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
000356  207a              MOVS     r0,#0x7a
000358  f7fffffe          BL       RCC_GetFlagStatus
00035c  b110              CBZ      r0,|L1.868|
;;;98         {
;;;99           printf("\r\n\n External Reset occurred....");
00035e  a060              ADR      r0,|L1.1248|
000360  f7fffffe          BL       __1printf
                  |L1.868|
;;;100        }
;;;101    
;;;102        printf("\r\n No need to configure RTC....");    
000364  a066              ADR      r0,|L1.1280|
000366  f7fffffe          BL       __1printf
;;;103        /* Wait for RTC registers synchronization */
;;;104        RTC_WaitForSynchro();
00036a  f7fffffe          BL       RTC_WaitForSynchro
;;;105    
;;;106        /* Enable the RTC Second */  
;;;107        RTC_ITConfig(RTC_IT_SEC, ENABLE);
00036e  2101              MOVS     r1,#1
000370  4608              MOV      r0,r1
000372  f7fffffe          BL       RTC_ITConfig
;;;108        /* Wait until last write operation on RTC registers has finished */
;;;109        RTC_WaitForLastTask();
000376  f7fffffe          BL       RTC_WaitForLastTask
                  |L1.890|
;;;110      }
;;;111    
;;;112      /* Clear reset flags */
;;;113      RCC_ClearFlag();
00037a  f7fffffe          BL       RCC_ClearFlag
;;;114      
;;;115      /* Display time in infinte loop */
;;;116      Time_Show();
00037e  f7fffffe          BL       Time_Show
;;;117    }
000382  2000              MOVS     r0,#0
000384  bd10              POP      {r4,pc}
;;;118    
                          ENDP

                  fputc PROC
;;;464    int fputc(int ch, FILE *f)
;;;465    {
000386  b570              PUSH     {r4-r6,lr}
000388  4604              MOV      r4,r0
00038a  460d              MOV      r5,r1
;;;466    #ifdef DBG_ITM
;;;467    /* 将Printf内容发往ITM激励寄存器端口  */
;;;468      if (DEMCR & TRCENA) {
;;;469        while (ITM_Port32(0) == 0);
;;;470        ITM_Port8(0) = ch;
;;;471      }
;;;472    #else  
;;;473    /* 将Printf内容发往串口 */
;;;474      USART_SendData(USART1, (unsigned char) ch);
00038c  b2e1              UXTB     r1,r4
00038e  480e              LDR      r0,|L1.968|
000390  f7fffffe          BL       USART_SendData
;;;475      while (!(USART1->SR & USART_FLAG_TXE));
000394  bf00              NOP      
                  |L1.918|
000396  480c              LDR      r0,|L1.968|
000398  8800              LDRH     r0,[r0,#0]
00039a  f0100f80          TST      r0,#0x80
00039e  d0fa              BEQ      |L1.918|
;;;476    #endif  
;;;477      return (ch);
0003a0  4620              MOV      r0,r4
;;;478    }
0003a2  bd70              POP      {r4-r6,pc}
;;;479    
                          ENDP

                  |L1.932|
0003a4  54696d65          DCB      "Time"
0003a8  3a202530          DCB      ": %0"
0003ac  2e32643a          DCB      ".2d:"
0003b0  25302e32          DCB      "%0.2"
0003b4  643a2530          DCB      "d:%0"
0003b8  2e32640d          DCB      ".2d\r"
0003bc  00000000          DCB      "\0\0\0\0"
                  |L1.960|
0003c0  0a0d0000          DCB      "\n\r\0\0"
                  |L1.964|
0003c4  00000000          DCD      TimeDisplay
                  |L1.968|
0003c8  40013800          DCD      0x40013800
                  |L1.972|
0003cc  0a0d506c          DCB      "\n\r\120\154"
0003d0  65617365          DCB      "ease"
0003d4  20656e74          DCB      " ent"
0003d8  65722076          DCB      "er v"
0003dc  616c6964          DCB      "alid"
0003e0  206e756d          DCB      " num"
0003e4  62657220          DCB      "ber "
0003e8  62657477          DCB      "betw"
0003ec  65656e20          DCB      "een "
0003f0  3020616e          DCB      "0 an"
0003f4  64203900          DCB      "d 9\0"
                  |L1.1016|
0003f8  0a0d506c          DCB      "\n\r\120\154"
0003fc  65617365          DCB      "ease"
000400  20656e74          DCB      " ent"
000404  65722076          DCB      "er v"
000408  616c6964          DCB      "alid"
00040c  206e756d          DCB      " num"
000410  62657220          DCB      "ber "
000414  62657477          DCB      "betw"
000418  65656e20          DCB      "een "
00041c  3020616e          DCB      "0 an"
000420  64202564          DCB      "d %d"
000424  00000000          DCB      "\0\0\0\0"
                  |L1.1064|
000428  00000000          DCD      ||.constdata||
                  |L1.1068|
00042c  0d0a2020          DCB      "\r\n\40\40"
000430  506c6561          DCB      "Plea"
000434  73652053          DCB      "se S"
000438  65742048          DCB      "et H"
00043c  6f757273          DCB      "ours"
000440  00000000          DCB      "\0\0\0\0"
                  |L1.1092|
000444  3a202025          DCB      ":  %"
000448  64000000          DCB      "d\0\0\0"
                  |L1.1100|
00044c  0d0a2020          DCB      "\r\n\40\40"
000450  506c6561          DCB      "Plea"
000454  73652053          DCB      "se S"
000458  6574204d          DCB      "et M"
00045c  696e7574          DCB      "inut"
000460  65730000          DCB      "es\0\0"
                  |L1.1124|
000464  0d0a2020          DCB      "\r\n\40\40"
000468  506c6561          DCB      "Plea"
00046c  73652053          DCB      "se S"
000470  65742053          DCB      "et S"
000474  65636f6e          DCB      "econ"
000478  64730000          DCB      "ds\0\0"
                  |L1.1148|
00047c  40011000          DCD      0x40011000
                  |L1.1152|
000480  40010800          DCD      0x40010800
                  |L1.1156|
000484  00000000          DCD      HSEStartUpStatus
                  |L1.1160|
000488  0d0a0a20          DCB      "\r\n\n\40"
00048c  52544320          DCB      "RTC "
000490  6e6f7420          DCB      "not "
000494  79657420          DCB      "yet "
000498  636f6e66          DCB      "conf"
00049c  69677572          DCB      "igur"
0004a0  65642e2e          DCB      "ed.."
0004a4  2e2e0000          DCB      "..\0\0"
                  |L1.1192|
0004a8  0d0a2052          DCB      "\r\n\40\122"
0004ac  54432063          DCB      "TC c"
0004b0  6f6e6669          DCB      "onfi"
0004b4  67757265          DCB      "gure"
0004b8  642e2e2e          DCB      "d..."
0004bc  2e000000          DCB      ".\0\0\0"
                  |L1.1216|
0004c0  0d0a0a20          DCB      "\r\n\n\40"
0004c4  506f7765          DCB      "Powe"
0004c8  72204f6e          DCB      "r On"
0004cc  20526573          DCB      " Res"
0004d0  6574206f          DCB      "et o"
0004d4  63637572          DCB      "ccur"
0004d8  7265642e          DCB      "red."
0004dc  2e2e2e00          DCB      "...\0"
                  |L1.1248|
0004e0  0d0a0a20          DCB      "\r\n\n\40"
0004e4  45787465          DCB      "Exte"
0004e8  726e616c          DCB      "rnal"
0004ec  20526573          DCB      " Res"
0004f0  6574206f          DCB      "et o"
0004f4  63637572          DCB      "ccur"
0004f8  7265642e          DCB      "red."
0004fc  2e2e2e00          DCB      "...\0"
                  |L1.1280|
000500  0d0a204e          DCB      "\r\n\40\116"
000504  6f206e65          DCB      "o ne"
000508  65642074          DCB      "ed t"
00050c  6f20636f          DCB      "o co"
000510  6e666967          DCB      "nfig"
000514  75726520          DCB      "ure "
000518  5254432e          DCB      "RTC."
00051c  2e2e2e00          DCB      "...\0"

                          AREA ||.data||, DATA, ALIGN=2

                  TimeDisplay
000000  00000000          DCD      0x00000000
                  HSEStartUpStatus
000004  00                DCB      0x00

                          AREA ||.constdata||, DATA, READONLY, ALIGN=2

000000  0d0a3d3d          DCB      0x0d,0x0a,0x3d,0x3d
000004  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000008  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
00000c  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000010  54696d65          DCB      0x54,0x69,0x6d,0x65
000014  20536574          DCB      0x20,0x53,0x65,0x74
000018  74696e67          DCB      0x74,0x69,0x6e,0x67
00001c  733d3d3d          DCB      0x73,0x3d,0x3d,0x3d
000020  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000024  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000028  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
00002c  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000030  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000034  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000038  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
00003c  3d3d3d3d          DCB      0x3d,0x3d,0x3d,0x3d
000040  3d3d00            DCB      0x3d,0x3d,0x00

                  __ARM_use_no_argv EQU 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -