#include "s5pc100.h"
#include "uart.h"
void key1_int(void);
void rtc_init(void);
void alm_int(void);
void bcd2str(unsigned int bcd, char *str);
char str[4];
int main()
{
int i;
uart_init();
rtc_init();
VIC0VECTADDR.VIC0VECTADDR28 = (unsigned int)alm_int;
VIC0INTERRUPT.VIC0INTENABLE = (1 << 28);
while (1) {
puts("Current time is: ");
bcd2str(RTCBCD.BCDHOUR & 0x3F, str);
puts(str);
puts(":");
bcd2str(RTCBCD.BCDMIN & 0x7F, str);
puts(str);
puts(":");
bcd2str(RTCBCD.BCDSEC & 0x7F, str);
puts(str);
puts("\n");
for (i = 0; i < 3600000; i++);
}
return 0;
}
void do_irq(void)
{
((void (*)(void))VIC0ADDRESS)();
VIC0ADDRESS = 0;
}
void alm_int(void)
{
puts("Please get up\n");
RTCINTP |= 1<<1;
}
void rtc_init(void)
{
RTCALARM.ALMSEC = 0x05;//设置闹铃时间
RTCALARM.RTCALM |= (1 << 6) | 1;//使能全局闹铃时钟,和秒闹铃时钟
RTCCON = 0X01;//RTC控制使能
//设置时间
RTCBCD.BCDSEC = 0x00;
RTCBCD.BCDMIN = 0x00;
RTCBCD.BCDHOUR = 0x12;
RTCBCD.BCDDATE = 0x15;
RTCBCD.BCDMON = 0x03;
RTCBCD.BCDYEAR = 0x12;
RTCCON = 0;//RTC控制关闭
}
void bcd2str(unsigned int bcd, char *str)
{
str[0] = ((bcd >> 4) & 0xF) + '0';
str[1] = ((bcd >> 0) & 0xF) + '0';
str[2] = '\0';
}
工程源码:
点击打开链接
Cortex A8,RTC程序
最新推荐文章于 2025-05-27 11:46:27 发布