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

using 89C4051.

Hello,
I have wired up a frequency meter using 89C4051.The signal is connected to P3.4/T0 pin.The circuit runs on 24MHz crystal.Can anyone give me the code of a frequency counter?Thanks in advance...

Parents
  • Completely unreadable! Post it formatted!

    Hi,
    I have arranged the program in correct order.Please go through it and let me know the mistakes...

    ISR PROGRAM
    ------------
    void timer0_isr(void)
    {

    while((tick--)!=0)
    timer0_isr_go();
    TR1=0;
    TF1=0;
    TR0=TF0=0;
    LCD_command(0x01);

    }

    void timer0_isr_go(void)
    { TH0=0x3C;
    TL0=0xBA;
    }

    void timer1_isr(void)
    { freq++;
    }

    SUBROUTINE
    ---------------

    void measure_freq()
    {

    unsigned char xx2,xx1,xx0; while(1)

    {

    LCD_command(0x01);

    TH0=0x3C;

    TL0=0xBA;

    tick=0x20;

    freq=0;

    TH1=0;

    TL1=0;

    TR0=TR1=1;

    while(TF0!=0);

    LCD_command(0x01);

    xx2=freq;

    xx1=TH1;

    xx0=TL1;

    init_serial();

    serial_data();

    printf ("\nValue of XX2 : %d ",xx2);

    printf ("\nValue of XX1 : %d ",xx1);

    printf ("\nValue of XX0 : %d ",xx0);

    } }

Reply
  • Completely unreadable! Post it formatted!

    Hi,
    I have arranged the program in correct order.Please go through it and let me know the mistakes...

    ISR PROGRAM
    ------------
    void timer0_isr(void)
    {

    while((tick--)!=0)
    timer0_isr_go();
    TR1=0;
    TF1=0;
    TR0=TF0=0;
    LCD_command(0x01);

    }

    void timer0_isr_go(void)
    { TH0=0x3C;
    TL0=0xBA;
    }

    void timer1_isr(void)
    { freq++;
    }

    SUBROUTINE
    ---------------

    void measure_freq()
    {

    unsigned char xx2,xx1,xx0; while(1)

    {

    LCD_command(0x01);

    TH0=0x3C;

    TL0=0xBA;

    tick=0x20;

    freq=0;

    TH1=0;

    TL1=0;

    TR0=TR1=1;

    while(TF0!=0);

    LCD_command(0x01);

    xx2=freq;

    xx1=TH1;

    xx0=TL1;

    init_serial();

    serial_data();

    printf ("\nValue of XX2 : %d ",xx2);

    printf ("\nValue of XX1 : %d ",xx1);

    printf ("\nValue of XX0 : %d ",xx0);

    } }

Children