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

configure Timer 2 on P89C51RD2

I'll very appreciate if you can help me with the following issue: Configured Timer 2 on P89C51RD2 .

I'm getting around me and become confused from it ...

So, I configure Timer 2 / 16-bit timer (the timer overflows (goes from 0xFFFF to 0x0000)

An interrupt service routine (ISR) have to be invoked whan timer 2 have expired.

(In which register I have to set the interrupt number void timer2_ISR (void) interrupt xx ??)

Can you send me a 'C' example code which demonstrated this issue.

Thanks

Moshe

Parents
  • Hi

    Thanks. It's works but u have to add EA=1

    Moshe


    /* init timer2 to required delay and start it*/
    static void timer2_init(void)
    {
    T2CON = 0x00; /* timer 2 16 bit auto-reload. */
    TL2 = TIMER2_CLK_TICK_RELOAD & 0xFF;
    TH2 = TIMER2_CLK_TICK_RELOAD % 0x0100;
    RCAP2L = TIMER2_CLK_TICK_RELOAD & 0xFF; /* lower byte of 16 bit reload value. */
    RCAP2H = TIMER2_CLK_TICK_RELOAD % 0x0100;/* upper byte of 16 bit reload value. */
    TR2 = 1; /* start timer 2. */
    ET2 = 1;

    EA = 1;
    }

Reply
  • Hi

    Thanks. It's works but u have to add EA=1

    Moshe


    /* init timer2 to required delay and start it*/
    static void timer2_init(void)
    {
    T2CON = 0x00; /* timer 2 16 bit auto-reload. */
    TL2 = TIMER2_CLK_TICK_RELOAD & 0xFF;
    TH2 = TIMER2_CLK_TICK_RELOAD % 0x0100;
    RCAP2L = TIMER2_CLK_TICK_RELOAD & 0xFF; /* lower byte of 16 bit reload value. */
    RCAP2H = TIMER2_CLK_TICK_RELOAD % 0x0100;/* upper byte of 16 bit reload value. */
    TR2 = 1; /* start timer 2. */
    ET2 = 1;

    EA = 1;
    }

Children
No data