大神们小弟有个程序还是不懂,这个程序运行后,在lcd需要经过好长时间才走秒,而且一秒的时间太长,大概有实际的五秒间隔,这要怎样修改?
#include "config.h"
#include "display.h"
#define RTC_NUM 13
#define
tiMER0NUM 4
#define uchar unsigned char
#define uint unsigned int
#define yearposi 0
#define monthposi 4
#define dayposi 6
#define hourposi 0
#define minposi 2
#define secposi 4
uint32 timer1cnt;
uint8 secflag,month,day,hour,min,sec,week,year,ctemp;
uint8 exint1flag;
uint8 premonth,preday,prehour,premin,presec,preyear,prectemp;
uint32 timet,datet;
uint8 time0flag,time1flag;
void RTC_init(void)
{
CCR=0X12;
CIIR=0X01;
ILR=0X03;
YEAR=2013;
MONTH=07;
DOM=05;
DOW=5;
HOUR=11;
MIN=11;
SEC=06;
CCR=0X11;
secflag=0;
}
void __irq RTC_int(void)
{
timet=CTIME0;
datet=CTIME1;
sec=timet&0x3f;
min=(timet>>8)&0x3f;
hour=(timet>>16)&0x1f;
week=(timet>>24)&0x07;
day=datet&0x1f;
month=(datet>>8)&0x0f;
year=((datet>>16)&0x0fff)%100;
ILR=0X01;
VICVectAddr=0x00;
secflag=1;
}
void RTC_int_ini(void)
{
VICIntSelect&=~(1<
VICVectCntl2=0x20|RTC_NUM;
VICVectAddr2=(uint32)RTC_int;
VICIntEnable=(1<
}
void init_port(void)
{
//port initialized
IO1DIR=0x00FF0000;
IO0DIR=0x40600010;
}
void init_timer0(void)
{
T0TCR=0X00;
T0TC=0X00;
T0PR=0;
T0MR0=Fpclk/2;
T0MCR=0X03;
T0TCR=0X01;
}
void timer0process(void)
{
if(time0flag==1)
{
time0flag=0;
}
}
void __irq timer0_int(void)
{
time0flag=1;
T0IR=0X01;
VICVectAddr=0x00;
}
void init_timer0_int(void)
{
VICIntSelect&=~(1<
VICVectCntl0=0x20|TIMER0NUM;
VICVectAddr0=(uint32)timer0_int;
VICIntEnable=1<
}
void freshdatetime()
{
if(secflag==1)
{
if(preyear!=year)
{
Displaydate(year,yearposi);
preyear=year;
}
if(premonth!=month)
{
Displaydate(month,monthposi);
premonth=month;
}
if(preday!=day)
{
Displaydate(day,dayposi);
displayweek(week);
preday=day;
}
if(prehour!=hour)
{
Displaytime(hour,hourposi);
prehour=hour;
}
if(premin!=min)
{
Displaytime(min,minposi);
premin=min;
}
if(presec!=sec)
{
Displaytime(sec,secposi);
presec=sec;
}
secflag=0;
}
}
void int_enable(void)
{
init_timer0_int();
}
int main (void)
{// add user source code
timer1cnt=0;
init_port();
Lcd_Init();
RTC_init();
RTC_int_ini();
init_timer0();
int_enable();
while(1)
{
freshdatetime();
timer0process();
}
}
0