本帖最后由 Jinss 于 2014-9-11 22:16 编辑
本来应该打印1:0.012:0.151:0.012:0.15
void interrupt0() interrupt 0
{
timercount = 0; //reset
IE = 0x0; //disable all interrupt
// TCON = 0x05; //0b0000 0101
//shutdown t0 and t1
//reset t0 and t1 interrupt flag bit
if(INTc == 0) //state1
{
//TCON = 0x01;//int0 negative edge triggered,int0
//low voltage triggered
uart();
IE = 0x83; //enable t0 and int0 inerrupt
TR0 = 1;
}
else //state2
{
uart();
IE = 0x89; //enable UART1,t1 and int0 interrupt
TR1 = 1;
}
INTc = ~INTc;
}
void uart()
{
unsigned char i;
unsigned char state1data[7]={"1:0.01"};
unsigned char state2data[7]={"2:0.15"};
RCAP2L = 0xdc;
RCAP2H = 0xff;
T2CON = 0x34; //timer2
SCON = 0x40; //0b0100 0000
//mode 1, receive disabled,
PCON = 0x0; //baudrate no multiply, frame no error check
|