话不多说,亮程序。串口上启动速度很多,但是用电源供电自己启动很慢,大概30多秒才运行完一起程序亮灯。
void main(void)
{
uint16 step=1,i=0;
int adc14[10],adc00[10],adc01[10],adc02[10],adc03[10],adc04[10],adc05[10],adc06[10],adc10[10],adc15[10]/;
/*textErroe();*/
reset_deng(); //复位亮下灯
Uart1Init();
Timer0_Init();
Timer1_Init();
//复位
ES = 1;
EA = 1;
step1_mode();
/*reset_mode();*/
//ADC10_Init();
while(1)
主程序如上
void Timer0_Init(void)
{
TMOD = 0x00; //模式0
TL0 = 0x00; //65536-11.0592M/12/1000 定时1ms
TH0 = 0x00;
//TR0 = 1; //启动定时器
// ET0 = 1; //使能定时器中断
// EA = 1;
}
void Timer1_Init(void)
{
TMOD = 0x00; //模式0
TL1 = 0x66; //65536-11.0592M/12/1000
TH1 = 0xfc;
TR1 = 1; //启动定时器
ET1 = 1; //使能定时器中断
EA = 1;
}
定时器初始化如上
下面是按键和灯。。灯很久才亮。
void TM1_Isr() interrupt 3 using 1
{
TL1 = 0x66; //65536-11.0592M/12/1000
TH1 = 0xfc;
if(P67==0){
reset_deng();
if(P67==0)
{
ISP_CONTR=0x20;
//((void (code *) (void)) 0x0000) ();
}
}
error_count++;
if(error_count==50)
{
error_count=0;
if(step1_error==1)
{
P55=!P55;
}
else if(step1_error==2)
P55=1;
else P55=0;
if(step2_error==1)
{
P40=!P40;
}
else if(step2_error==2)
P40=1;
else P40=0;
if(step3_error==1)
{
P64=!P64;
}
else if(step3_error==2)
P64=1;
else P64=0;
if(step4_error==1||step5_error==1)
{
P65=!P65;
}
else if(step4_error==2)
P65=1;
else P65=0;
if(step1_error==0&&step2_error==0&&step3_error==0&&step4_error==0&&step5_error==0)
{
P66=0;
}
else
P66=1;
}
}
|