GNU ARM汇编--(十)s3c2440的RTC
rtc_uart_test.s: 本文引用地址: //m.amcfsurvey.com/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的闹钟也实现了功能.明天就用这个做闹钟吧~~
评论