首页 > 其他 > 详细

Cortex A8,RTC程序

时间:2014-04-01 19:00:05      阅读:698      评论:0      收藏:0      [点我收藏+]
#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程序,布布扣,bubuko.com

Cortex A8,RTC程序

原文:http://blog.csdn.net/it_liuwei/article/details/22738821

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!