我用西尔特的编程器烧录P89LPC902FN,软件提示烧录成功,但是放到实际电路中没有一点反映.
用的是看门狗定时器,让 p0.0每隔一秒输出低电平,请问是什么问题,是不是配置文件的错误?急求!谢谢
#include<REG902.h>
#define uint unsigned int
#define uchar unsigned char
uint tt;
sbit LEDRUN = P0^0;
uchar init_ucfg();
void init_timer0 (void);
void watch_feed();
void Delay(uint tt);
void main()
{ uchar t;
P0M1=0x00;
do
{ t=init_ucfg();}
while(t);
P0=0x00;
watch_feed();
init_timer0();
while(1);
}
/*======================== 延时子程序 ======================*/
void Delay(uint tt)
{
while (tt--);
}
/*======================== 配置寄存器====================== */
uchar init_ucfg()
{ uchar ucfg_stat;
uchar ucfg_result;
FMADRL=0x00;
FMCON=0x6C;
FMDATA=0x84;
ucfg_stat=FMCON;
if ( (ucfg_stat&0x0F) !=0 ) ucfg_result =1; else ucfg_result = 0;
return ucfg_result;
}
/*======================== 定时中断初始化 ======================*/
void init_timer0()
{
TMOD = 0x11; //0x20 TMOD: timer 0, mode 1, 16-bit
TH0 = 0xB1;
TL0 = 0xE0;
EA=1;
ET0 = 1;
TR0 = 1;
}
/*======================== 定时中断======================*/
void timers0() interrupt 1 using 1
{ int i;
WDL=0xff;
EA = 0;
WFEED1 = 0xA5;
WFEED2 = 0x5A;
EA=1;
TH0 = 0xB1;
TL0 = 0xE0;
i++;
if(i==10)
{ LEDRUN=~LEDRUN;
}
/*======================== 看门狗清零序列 ======================*/
void watch_feed()
{ bit eacopy;
eacopy = EA;
WDL=0xFF;
EA = 0;
WDCON=0xC5;
WFEED1 = 0xA5;
WFEED2 = 0x5A;
EA=1;
EA = eacopy;
}
|