GNU ARM匯編--(十)s3c2440的RTC
rtc_uart_test.s:本文引用地址:http://butianyuan.cn/article/201611/321721.htm
[cpp]view plaincopy
- #include
- #include
- #include
- #include
- #include
- #include"rtc_uart_test.h"
- externvoidBuzzer_Freq_Set(intfreq);
- //externvoidBuzzer_Freq_Set(void);
- charuart_GetByte(void)
- {
- while(!(rUTRSTAT0&0x1));//WaituntilTHRisempty.
- returnRdURXH0();
- }
- voiduart_GetString(char*pt)
- {
- while(*pt)
- uart_GetByte();
- }
- voiduart_SendByte(intdata)
- {
- if(data==)
- {
- while(!(rUTRSTAT0&0x2));
- WrUTXH0();
- }
- while(!(rUTRSTAT0&0x2));//WaituntilTHRisempty.
- WrUTXH0(data);
- }
- //====================================================================
- voiduart_SendString(char*pt)
- {
- while(*pt)
- uart_SendByte(*pt++);
- }
- voiduart_Printf(char*fmt,...)
- {
- va_listap;
- charstring[256];
- va_start(ap,fmt);
- //vsprintf(string,fmt,ap);
- uart_SendString(string);
- va_end(ap);
- }
- voiduart_test(void)
- {
- charstr[20]="helloworld";
- inta=97;
- //while(1)
- //uart_SendByte(a);
- uart_SendString(str);
- chars=uart_GetByte();
- //if(s==a)
- if(s==97)
- rGPBDAT=0x1c0;
- //uart_SendByte(a);
- //uart_SendByte(97);
- //uart_SendByte(a);
- uart_SendByte((int)s);
- uart_SendByte((int)s);
- }
- voidrtc_uart_test(void)
- {
- rRTCCON=0x1;
- rTICNT=0x0;
- rRTCALM=0x42;
- rBCDYEAR=0x10;
- rBCDMON=0x11;
- rBCDDATE=0x07;
- rBCDDAY=0x05;
- rBCDHOUR=0x12;
- rBCDMIN=0x03;
- rBCDSEC=0x00;
- rALMMIN=0x04;
- uart_SendString("begin");
- //uart_Printf("year:%d",rBCDYEAR);
- }
- voidpwm_uart_test(void)
- {
- intfreq=10;
- inti;
- for(i=0;i<100;i++)
- uart_SendString("app");
- //Buzzer_Freq_Set(freq);
- //Buzzer_Freq_Set();
- //uart_test();
- uart_SendString("start");
- /*
- inti;
- for(i=0;i<1000;i++)
- uart_SendString("wait");
- while(1)
- {
- charkey=uart_GetByte();
- uart_SendByte(key);
- if(key==a||key==A)
- {
- if(freq<2000)//lci20000
- freq+=10;
- uart_SendByte(a);
- Buzzer_Freq_Set(freq);
- }
- if(key==b||key==B)
- {
- if(freq>11)
- freq-=10;
- uart_SendByte(b);
- Buzzer_Freq_Set(freq);
- }
- //uart_SendString(" Freq=%d",freq);
- //if(key==ESC_KEY)
- //{
- //Buzzer_Stop();
- //return;
- //}
- }
- */
- }
在調這個過程中,因為RTCCON中的CLKRST最初被我置為1,導致時間根本不走,為了查這個問題,專門通過led顯示來判斷這個時間是不是不走:
ldr r2, =BCDSEC @BCDMIN
ldr r1,[r2]
cmp r1, #0x06
bleq ledon
通過這里的判斷,可以明確時間有被設進去,可是時間不走.經過google,才確定是寄存器的設置問題.
到此,rtc的鬧鐘也實現了功能.明天就用這個做鬧鐘吧~~
評論