Connect with us

8051 interfacing with ADC 0808

Discussion in 'Microcontrollers, Programming and IoT' started by BluePhoenix, Mar 6, 2016.

Scroll to continue with content
  1. BluePhoenix

    BluePhoenix

    1
    0
    Mar 6, 2016
    Hey everyone,
    Recently I got into a project which requires the use of 8051. The project is mainly about interfacing 8051 with an ADC 0808 by a temperature sensor LM35. So I got a circuit and wrote the corresponding program for 8051. The trouble is, the program gets compiled in RIDE but doesn't work in the circuit when simulated using Proteus (version 7). I have attached both, the circuit diagram and the code for the 8051. Can anybody tell me what I am doing wrong and how I should correct it? Any help is very much appreciated as soon as possible. adcinterfacing.jpg

    And the corresponding code is:
    #include <reg51.h>
    #define input P3

    sbit START=P3^0;
    sbit EOC=P3^1;
    sbit OE=P3^2;
    sbit ADD_A = P3^3;
    sbit ADD_B = P3^4;
    sbit ADD_C = P3^5;
    sbit ALE = P3^6;
    sbit OUT1 = P0^0;
    sbit OUT2 = P0^1;
    sbit OUT3 = P0^2;
    sbit OUT4 = P0^3;
    sbit OUT5 = P0^4;
    sbit OUT6 = P0^5;
    sbit OUT7 = P0^6;
    sbit OUT8 = P0^7;

    unsigned char temp, c, i, j;

    void delay()
    {
    for(i=0;i<1000;i++);
    for(j=0;j<100;j++);
    }

    unsigned char adc_data (unsigned char c)
    {
    ADD_A=0;
    ADD_B=0;
    ADD_C=0;
    START=1;
    ALE=1;
    delay();
    ALE=0;
    START=0;
    while(EOC==1)
    {
    OE=1;
    delay();
    c=P0;
    delay();
    OE=0;

    }
    return c;
    }

    void main()
    {
    unsigned char d;
    EOC=0;
    ALE=0;
    START=0;
    ADD_A=0;
    ADD_B=0;
    ADD_C=0; //initial values

    while(1)
    {
    temp=adc_data(c);
    d=temp;
    P1=d;
    }

    }
     
  2. Anon_LG

    Anon_LG

    453
    117
    Jun 24, 2014
    I see an inversion bubble on the resets of your bistables. Should they be tied high instead?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-