Results 1 to 2 of 2

Thread: 8051 based frequency counter using external interrupts.

  1. #1
    hassan
    Guest

    8051 based frequency counter using external interrupts.

    hi
    i want to get the code for frquency counter using 8051 with the help of external interrupts as i have also i folows and is not running properly. kindly help me in this matter.
    code is :
    #include <AT89X51.h>
    # define T1 P3_2
    #define RS P0_0
    #define RW P0_1
    #define E P0_2
    #define dataline P2
    void Delay(unsigned int time)
    {
    unsigned int i;
    unsigned int j;
    for(j=0;j<time;j++)
    for(i=0;i<127;i++)
    ;
    }
    void lcddata(unsigned char j)
    {
    dataline=j;
    RS=1;
    RW=0;
    E=1;
    Delay(10);
    E=0;
    Delay(50);
    }
    void lcdcmd(unsigned char j)
    {
    dataline=j;
    RS=0;
    RW=0;
    E=1;
    Delay(10);
    E=0;
    Delay(50);
    }

    void Convert_Display(unsigned char value)
    {
    unsigned char x,d1,d2,d3;
    x=value/10;
    d1=value%10;
    d2=x%10;
    d3=x/10;
    lcdcmd(0x38);
    lcdcmd(0x0E);
    lcdcmd(0x01);
    lcdcmd(0x06);
    lcdcmd(0x86);
    Delay(50);
    lcddata(d3+'0');
    Delay(50);
    lcddata(d2+'0');
    Delay(50);
    lcddata(d1+'0');
    Delay(50);
    }
    unsigned char value;
    void timer0() interrupt 0
    {

    TH1=0;


    TL1=1;
    value=TL1;
    Convert_Display(value);
    TR0=1;
    TH1=1;
    }
    void main(void)
    {T1=1;

    IE=0x81;

    TMOD=0x06;


    IT0=1;
    EX0 = 1; // Enable EX0 Interrupt

    EA = 1; // Enable Global Interrupt Flag


    while(1); }

  2. #2
    Lead Engineer RWOLFEJR's Avatar
    Join Date
    Mar 2011
    Location
    Rochester Pennsylvania
    Posts
    396
    If you type 8051 controller code in your favorite search engine a lot of things come up that should help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •