新聞中心

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

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

        作者: 時間:2016-11-26 來源:網絡 收藏
      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@死循環
      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.104case.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. }

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

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

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

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


        上一頁 1 2 3 下一頁

        關鍵詞: ARM匯編s3c2440RT

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 凌海市| 齐河县| 雷山县| 城步| 陇南市| 枣阳市| 泸定县| 青田县| 建水县| 三河市| 即墨市| 广水市| 来宾市| 西畴县| 海淀区| 务川| 五峰| 合作市| 汶川县| 开封县| 汤阴县| 丽水市| 高雄市| 海口市| 松阳县| 琼结县| 阳朔县| 昌黎县| 边坝县| 富裕县| 弥渡县| 繁昌县| 增城市| 黄骅市| 泉州市| 桐梓县| 共和县| 阿勒泰市| 长沙县| 新乐市| 登封市|