新闻中心

EEPW首页>嵌入式系统>设计应用> GNU ARM汇编--(十)s3c2440的RTC

GNU ARM汇编--(十)s3c2440的RTC

作者: 时间:2016-11-26 来源:网络 收藏
  • 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@死循环
  • 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:

    本文引用地址: //m.amcfsurvey.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

    评论


    相关推荐

    技术专区

    关闭