<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > GNU ARM匯編--(十)s3c2440的RTC

          GNU ARM匯編--(十)s3c2440的RTC

          作者: 時間:2016-11-26 來源:網(wǎng)絡 收藏
        1. ldrr0,=TCFG0
        2. ldrr1,=(Prescaler0<<0)
        3. strr1,[r0]
        4. ldrr0,=TCFG1
        5. ldrr1,=(DMA_MODE<<20)|(MUX0<<0)
        6. strr1,[r0]
        7. ldrr0,=TCNTB0
        8. ldrr1,=10
        9. strr1,[r0]
        10. ldrr0,=TCMPB0
        11. ldrr1,=2
        12. strr1,[r0]
        13. ldrr0,=TCON
        14. ldrr1,=(DZ_eable<<4)|(auto_reload<<3)|(inverter<<2)|(man_update<<1)|(start<<0)
        15. strr1,[r0]
        16. ldrr0,=TCON
        17. ldrr1,=(DZ_eable<<4)|(auto_reload<<3)|(inverter<<2)|(clear_man_update<<1)|(start<<0)
        18. strr1,[r0]
        19. */
        20. ldrlr,=loop
        21. //ldrpc,_rtc_uart_test
        22. //_rtc_uart_test:.wordrtc_uart_test
        23. blrtc_uart_test
        24. ldrr2,=GPBDAT
        25. ldrr1,=0x1c0
        26. strr1,[r2]
        27. bldelay
        28. loop:
        29. ldrr2,=BCDSEC@BCDMIN
        30. ldrr1,[r2]
        31. cmpr1,#0x06
        32. bleqledon
        33. bloop@死循環(huán)
        34. ledon:
        35. ldrr2,=GPBDAT
        36. ldrr1,=0x160
        37. strr1,[r2]
        38. ldrr3,=0xffffff
        39. delay3:
        40. subr3,r3,#1
        41. cmpr3,#0x0
        42. bnedelay3
        43. movpc,lr
        44. undefined_instruction:
        45. nop
        46. software_interrupt:
        47. nop
        48. prefetch_abort:
        49. nop
        50. data_abort:
        51. nop
        52. not_used:
        53. nop
        54. fiq:
        55. nop

        56. rtc_uart_test.s:

          本文引用地址:http://www.ex-cimer.com/article/201611/321721.htm

          [cpp]view plaincopy
          1. #include
          2. #include
          3. #include
          4. #include
          5. #include
          6. #include"rtc_uart_test.h"
          7. externvoidBuzzer_Freq_Set(intfreq);
          8. //externvoidBuzzer_Freq_Set(void);
          9. charuart_GetByte(void)
          10. {
          11. while(!(rUTRSTAT0&0x1));//WaituntilTHRisempty.
          12. returnRdURXH0();
          13. }
          14. voiduart_GetString(char*pt)
          15. {
          16. while(*pt)
          17. uart_GetByte();
          18. }
          19. voiduart_SendByte(intdata)
          20. {
          21. if(data==)
          22. {
          23. while(!(rUTRSTAT0&0x2));
          24. WrUTXH0();
          25. }
          26. while(!(rUTRSTAT0&0x2));//WaituntilTHRisempty.
          27. WrUTXH0(data);
          28. }
          29. //====================================================================
          30. voiduart_SendString(char*pt)
          31. {
          32. while(*pt)
          33. uart_SendByte(*pt++);
          34. }
          35. voiduart_Printf(char*fmt,...)
          36. {
          37. va_listap;
          38. charstring[256];
          39. va_start(ap,fmt);
          40. //vsprintf(string,fmt,ap);
          41. uart_SendString(string);
          42. va_end(ap);
          43. }
          44. voiduart_test(void)
          45. {
          46. charstr[20]="helloworld";
          47. inta=97;
          48. //while(1)
          49. //uart_SendByte(a);
          50. uart_SendString(str);
          51. chars=uart_GetByte();
          52. //if(s==a)
          53. if(s==97)
          54. rGPBDAT=0x1c0;
          55. //uart_SendByte(a);
          56. //uart_SendByte(97);
          57. //uart_SendByte(a);
          58. uart_SendByte((int)s);
          59. uart_SendByte((int)s);
          60. }
          61. voidrtc_uart_test(void)
          62. {
          63. rRTCCON=0x1;
          64. rTICNT=0x0;
          65. rRTCALM=0x42;
          66. rBCDYEAR=0x10;
          67. rBCDMON=0x11;
          68. rBCDDATE=0x07;
          69. rBCDDAY=0x05;
          70. rBCDHOUR=0x12;
          71. rBCDMIN=0x03;
          72. rBCDSEC=0x00;
          73. rALMMIN=0x04;
          74. uart_SendString("begin");
          75. //uart_Printf("year:%d",rBCDYEAR);
          76. }
          77. voidpwm_uart_test(void)
          78. {
          79. intfreq=10;
          80. inti;
          81. for(i=0;i<100;i++)
          82. uart_SendString("app");
          83. //Buzzer_Freq_Set(freq);
          84. //Buzzer_Freq_Set();
          85. //uart_test();
          86. uart_SendString("start");
          87. /*
          88. inti;
          89. for(i=0;i<1000;i++)
          90. uart_SendString("wait");
          91. while(1)
          92. {
          93. charkey=uart_GetByte();
          94. uart_SendByte(key);
          95. if(key==a||key==A)
          96. {
          97. if(freq<2000)//lci20000
          98. freq+=10;
          99. uart_SendByte(a);
          100. Buzzer_Freq_Set(freq);
          101. }
          102. if(key==b||key==B)
          103. {
          104. if(freq>11)
          105. freq-=10;
          106. uart_SendByte(b);
          107. Buzzer_Freq_Set(freq);
          108. }
          109. //uart_SendString(" Freq=%d",freq);
          110. //if(key==ESC_KEY)
          111. //{
          112. //Buzzer_Stop();
          113. //return;
          114. //}
          115. }
          116. */
          117. }

          在調(diào)這個過程中,因為RTCCON中的CLKRST最初被我置為1,導致時間根本不走,為了查這個問題,專門通過led顯示來判斷這個時間是不是不走:

          ldr r2, =BCDSEC @BCDMIN
          ldr r1,[r2]
          cmp r1, #0x06
          bleq ledon

          通過這里的判斷,可以明確時間有被設進去,可是時間不走.經(jīng)過google,才確定是寄存器的設置問題.

          到此,rtc的鬧鐘也實現(xiàn)了功能.明天就用這個做鬧鐘吧~~


          上一頁 1 2 3 下一頁

          關(guān)鍵詞: ARM匯編s3c2440RT

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();