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
  • Hi,
    I am unable to get the detail from your program.Please go through the code I have done.Thanks in advance....

    IN ISR
    -------------
    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++;
    }

    IN MAIN PROGRAM
    ----------------

    void measure_freq()
    { unsigned char xx2[5],xx1,xx0[5]; 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); timer0_isr(); timer1_isr(); } *xx2=freq; xx1=TH1; *xx0=TL1; n=strlen(xx0); LCD_row1(); print_str_lcd(xx0,n); LCD_row2(); LCD_puts("xx1");

    init_serial(); serial_data(); printf ("\nValue of XX2 : %d ",xx2); printf ("\nValue of XX1 : %d ",xx1); printf ("\nValue of XX0 : %d ",xx0);

    } }

Reply
  • Hi,
    I am unable to get the detail from your program.Please go through the code I have done.Thanks in advance....

    IN ISR
    -------------
    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++;
    }

    IN MAIN PROGRAM
    ----------------

    void measure_freq()
    { unsigned char xx2[5],xx1,xx0[5]; 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); timer0_isr(); timer1_isr(); } *xx2=freq; xx1=TH1; *xx0=TL1; n=strlen(xx0); LCD_row1(); print_str_lcd(xx0,n); LCD_row2(); LCD_puts("xx1");

    init_serial(); serial_data(); printf ("\nValue of XX2 : %d ",xx2); printf ("\nValue of XX1 : %d ",xx1); printf ("\nValue of XX0 : %d ",xx0);

    } }

Children