This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Serial and timer seem conflict

void enable_timer(void)
{
TH0=0x01;
TL0=0x01;
TMOD = (TMOD & 0xF0) | 0x01;
ET0 = 1;
TR0 = 1;
EA = 1;
}

void serial_init(void)
{
PCON |= 0x80;
SCON = 0x52;
TMOD |= 0x20;
TH1 = 0xF3;
TR1 = 1;
ES = 1;
// PS = 1;
EA = 1;
}

I don't know why when i use 2 subs to initialize serial port and timer 0 but i don't know why timer 0 runs so slowly.Could anyone can tell me the reason why and show me the solution?Please answer me soon because I need it

  • Hi,

    I haven't checked the rest of the timer 0 initialisation, but dont forget the counter counts up to 0xFFFF, not down to 0x0000! and you initialise it with 0x0101 so it has a long way to go. Is this what you intended?

    Mark.

  • How is CKCON set? what is clocking T0?
    Read-modify-write ops are used on TMOD, what is the absolute initial value?
    What is the state of the T1 interrupt?
    If you set TR1=0 does T0 run differently?
    Use your simulator and watch the peripheral windows, you'll see what's wrong.