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

8051 timer to sleep for a few second

Does anybody know how to set 8051 timer to sleep for a few second and then wake up by itself?

Parents
  • Well, it probably helps to show the whole section of code so that the comment really makes sense.

    /*------------------------------------------------
    Setup TIMER0 to generate a regular interupt.
    ------------------------------------------------*/
    TR0 = 0;           /* Stop Timer 0 */
    
    TMOD &= ~0x0F;     /* 16-bit, no prescale mode */
    TMOD |=  0x01;
    
    TL0 = 0;           /* Set T0 */
    TH0 = 0;
    
    PT0 = 0;           /* Low Priority Interrupt */
    ET0 = 1;           /* Enable Timer0 Interrupt */
    
    TR0 = 1;           /* Start Timer 0 */
    EA = 1;            /* Enable Global Interrupts */

    TMOD is the Timer MODE Register. It is documented in the 8051 data sheet.

    Jon

Reply
  • Well, it probably helps to show the whole section of code so that the comment really makes sense.

    /*------------------------------------------------
    Setup TIMER0 to generate a regular interupt.
    ------------------------------------------------*/
    TR0 = 0;           /* Stop Timer 0 */
    
    TMOD &= ~0x0F;     /* 16-bit, no prescale mode */
    TMOD |=  0x01;
    
    TL0 = 0;           /* Set T0 */
    TH0 = 0;
    
    PT0 = 0;           /* Low Priority Interrupt */
    ET0 = 1;           /* Enable Timer0 Interrupt */
    
    TR0 = 1;           /* Start Timer 0 */
    EA = 1;            /* Enable Global Interrupts */

    TMOD is the Timer MODE Register. It is documented in the 8051 data sheet.

    Jon

Children
No data