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

plz any one tell me how to work with timer.

plz any one tell me how to work with timer.

i m working with p89v51rd2.
in that i m trying to a simple program which showing the numbers on led as counter.

logic of my program is when one cycle is complete of timer than number have to change.

but i m not able to do this.

TMOD=0x20; that is for timer for 2 mode which 16 bit
TH1=0xf3; that is for 2400 bugd rate but convert to 9600

any one help me plz.....

Parents
  • #include <P89V51Rx2.H>
    #define char unsigned char
    #define int unsigned int
    char timecount,move;
    /********************************************************* The main function
    **********************************************************/
    
    void main()
    { P2=0xff; //Commissioner of all the lights
    TMOD=0x01; //Timing / Counter 0 work in a way TH0=0x4C;
    TL0=0x00; //50ms time constants
    EA=1; //A total interruption
    ET0=1; //Allow time / Counter 0 interrupted
    TR0=1; //Start time / Counter 0 interrupted
    move=0xfe;
    while(1);
    } /********************************************************* Interrupt service function
    **********************************************************/
    void Time0(void) interrupt 1 // using 0
    {
    TH0=0x4c; //50ms timing
    TL0=0x00;
    timecount++;
    if(timecount==10)
    {
    timecount=0;
    P2=move;
     move=(move <<1)|0x01;
    if(move==0xff)
     move=0xfe;
    }
    }
    

    in that program led was blink but i m not able to interface with 7 segment display. who could do this plz tell me

Reply
  • #include <P89V51Rx2.H>
    #define char unsigned char
    #define int unsigned int
    char timecount,move;
    /********************************************************* The main function
    **********************************************************/
    
    void main()
    { P2=0xff; //Commissioner of all the lights
    TMOD=0x01; //Timing / Counter 0 work in a way TH0=0x4C;
    TL0=0x00; //50ms time constants
    EA=1; //A total interruption
    ET0=1; //Allow time / Counter 0 interrupted
    TR0=1; //Start time / Counter 0 interrupted
    move=0xfe;
    while(1);
    } /********************************************************* Interrupt service function
    **********************************************************/
    void Time0(void) interrupt 1 // using 0
    {
    TH0=0x4c; //50ms timing
    TL0=0x00;
    timecount++;
    if(timecount==10)
    {
    timecount=0;
    P2=move;
     move=(move <<1)|0x01;
    if(move==0xff)
     move=0xfe;
    }
    }
    

    in that program led was blink but i m not able to interface with 7 segment display. who could do this plz tell me

Children