新聞中心

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

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

作者: 時間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
  • ldrr0,=TCFG0
  • ldrr1,=(Prescaler0<<0)
  • strr1,[r0]
  • ldrr0,=TCFG1
  • ldrr1,=(DMA_MODE<<20)|(MUX0<<0)
  • strr1,[r0]
  • ldrr0,=TCNTB0
  • ldrr1,=10
  • strr1,[r0]
  • ldrr0,=TCMPB0
  • ldrr1,=2
  • strr1,[r0]
  • ldrr0,=TCON
  • ldrr1,=(DZ_eable<<4)|(auto_reload<<3)|(inverter<<2)|(man_update<<1)|(start<<0)
  • strr1,[r0]
  • ldrr0,=TCON
  • ldrr1,=(DZ_eable<<4)|(auto_reload<<3)|(inverter<<2)|(clear_man_update<<1)|(start<<0)
  • strr1,[r0]
  • */
  • ldrlr,=loop
  • //ldrpc,_rtc_uart_test
  • //_rtc_uart_test:.wordrtc_uart_test
  • blrtc_uart_test
  • ldrr2,=GPBDAT
  • ldrr1,=0x1c0
  • strr1,[r2]
  • bldelay
  • loop:
  • ldrr2,=BCDSEC@BCDMIN
  • ldrr1,[r2]
  • cmpr1,#0x06
  • bleqledon
  • bloop@死循環(huán)
  • ledon:
  • ldrr2,=GPBDAT
  • ldrr1,=0x160
  • strr1,[r2]
  • ldrr3,=0xffffff
  • delay3:
  • subr3,r3,#1
  • cmpr3,#0x0
  • bnedelay3
  • movpc,lr
  • undefined_instruction:
  • nop
  • software_interrupt:
  • nop
  • prefetch_abort:
  • nop
  • data_abort:
  • nop
  • not_used:
  • nop
  • fiq:
  • nop

  • rtc_uart_test.s:

    本文引用地址:http://m.butianyuan.cn/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,導(dǎo)致時間根本不走,為了查這個問題,專門通過led顯示來判斷這個時間是不是不走:

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

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

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


    上一頁 1 2 3 下一頁

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

    評論


    相關(guān)推薦

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

    關(guān)閉