微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 第8课:WatchDog定时器和RTC

第8课:WatchDog定时器和RTC

时间:11-11 来源:互联网 点击:

void showtime() //ignore one second devition
{
uart_write("\r\nNow,the RTC time is:\r\nYear:20");
char a;
a = (char)rBCDYEAR;
bcd2uart(a);
uart_write(" Month:");
a = (char)rBCDMON;
bcd2uart(a);
uart_write(" Date:");
a = (char)rBCDDATE;
bcd2uart(a);
uart_write(" Hour:");
a = (char)rBCDHOUR;
bcd2uart(a);
uart_write(" Min:");
a = (char)rBCDMIN;
bcd2uart(a);
uart_write(" Sec:");
a = (char)rBCDSEC;
bcd2uart(a);
uart_write("\r\n");
}
void ISR_Handle()
{
int n;
char select,a;
n = rINTOFFSET;
switch(n){
case 28: //take a choice by int
if(rSUBSRCPND = 0){
while(!(rUTRSTAT0 & 0x1));
select = rURXH0;
rUTXH0 = select;
switch(select){
case 1:settime();break;
case 2:setalarmtime();break;
case 3:showtime();break;
default:uart_write("please input in 1 to 3\r\n");
}
}
break;
case 30: //when alarm clock reach,int_rtc will actived
uart_write("\r\nAlarm!!!");
uart_write(":");
a = (char)rBCDHOUR;
bcd2uart(a);
uart_write(":");
a = (char)rBCDMIN;
bcd2uart(a);
uart_write(":");
a = (char)rBCDSEC;
bcd2uart(a);
uart_write("\r\n");
break;
default:uart_write("undefined interrupt\r\n");
}
rSUBSRCPND = 1;
rSRCPND = 5<28;
rINTPND = 5<28;
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top