我试过在main里面用定时器2计时5秒后,启动T4,一启动T2就不工作了
//-----------------------Timer1 SET-----------------------
TR2 = 0; //stop timer1
TF2 = 0;
T2CON = Bin(00000000); //P44
T2MOD = Bin(00000000); //P45
//TL2 = LOBYTE(CLOCK_250US);
//TH2 = HIBYTE(CLOCK_250US);
TL2 = 0x50; //设置定时初值
TH2 = 0xFB; //设置定时初值
RCAP2L = 0x50; //设置定时重载值
RCAP2H = 0xFB; //设置定时重载值
TR2 = 1; //定时器2开始计时
/*-----------------------Timer4 SET-----------------------*/
TR4 = 0;
TF4 = 0;
T4CON = Bin(00000100); //设置Timer4用于产生波特率(baudrate generator)
TL4 = LOBYTE(UART_BAUDRATE); //P48
TH4 = HIBYTE(UART_BAUDRATE); //P48
PCON &= Bin(10111111); //P84 set SSTAT 0
ES=0;
SCON = Bin(01010000); //P83 设置串口通讯方式为8位异步通讯,波特率可变。
//TR4 = 1; //start timer4
/*-------------------------IE SET-------------------------*/
//使能ADC中断和Timer1中断
// Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
IEN0 = Bin(00110000); //P53 IEN0 EA EADC ET2 ES0 N/A EX1 ET5 EX0
IEN1 = Bin(01000000); //P54 IEN1 ESCM/ELPD ET4 EPWM ET3 EX4 EX3 EX2 N/A
} |