44B0 RTC时钟中断问题?
44B0时钟显示程序,利用滴答中断更新显示, 不过一直无法进入中断(不用中断设置读取时间没有问题), 时钟没有电池网上有人说44b0的RTC时钟有BUG, 大家帮忙看看, 中断应该没问题, 能进入 Timer0 中断
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\rtc.h"
#define RTC_ENABLE() rRTCCON = 0x01 /* RTC read enable */
#define RTC_DISABLE() rRTCCON = 0x0
void __irq Rtc_ISR(void);
typedef struct
{
U16 year;
U8 month;
U8 day;
U8 week;
U8 hour;
U8 min;
U8 sec;
}RTCTime;
RTCTime rtctime;
void __irq Rtc_ISR(void)
{
rI_ISPC = BIT_TICK;
RTC_ENABLE();
rtctime.year = rBCDYEAR + 2000;
rtctime.month = rBCDMON;
rtctime.day = rBCDDAY;
rtctime.week =rBCDDATE;
rtctime.hour = rBCDHOUR;
rtctime.min = rBCDMIN;
rtctime.sec = rBCDSEC;
RTC_DISABLE();
Uart_Printf("%d-%d-%d,%d,%d:%d:%d",rtctime.year,rtctime.month,
rtctime.day,rtctime.week,rtctime.hour,rtctime.min,rtctime.sec);
}
void RtcInit(void)
{
RTC_ENABLE();
rBCDYEAR = 10;
rBCDMON = 6;
rBCDDAY = 12;
rBCDDATE = 5;
rBCDHOUR = 0;
rBCDMIN = 0;
rBCDSEC = 0;
RTC_DISABLE();
pISR_TICK = (unsigned)Rtc_ISR;
RTC_ENABLE();
rINTMSK &= ~(BIT_GLOBAL|BIT_TICK);
rTICINT = 127+(1<<7); //enable tick interupt (127+1)/128 = 1s
RTC_DISABLE();
}
/********************************
能进入定时器0中断
void __irq Timer0_ISR(void)
{
static U32 count10ms=0,count50ms=0;
rI_ISPC = BIT_TIMER0;
System1MS=1;
if(++count10ms>10)
{
count10ms=0;
System10MS=1;
}
if(++count50ms>50)
{
count50ms=0;
System50MS=1;
}
}
void Timer0Init(void)
{
// enable_IRQ();
rINTMSK &= ~(BIT_TIMER0|BIT_GLOBAL); //允许timer0中断
pISR_TIMER0 = (unsigned)Timer0_ISR;
rTCFG0 = 0xff; // 预分频值 255 MCLK 40M
rTCFG1 = 0x0; // 时钟分割值 2 Timer时钟=40/256/2=78.125k 12.8us
rTCNTB0 = 0x4e; // 延时998.4us
rTCON = 0x6; // 停止Timer0,手动更新,反转器开,不自动重载
Delay(20);
rTCON = 0x9; // 开始Timer0,不手动更新,反转器关,自动重载
} 没人哩 楼主还在不?我也遇到了同样的问题,你的问题怎么解决的啊?求帮助。。。
页:
[1]