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

problems in Interfacing ADC and 89C51

Hi,
I'm a 3rd year undergrad student in ECE.
I'm trying to interface an ADC0809 with Atmel 89C51.
The adc is working fine, it gives proper digital output for all values from 0-5V.The adc is configured in continuous conversion mode. I'm trying to read the output of the ADC through port 1 of 8051, but I see that the port1 is not reading the digital output. I'm not able to figure out what could be the problem.
I wrote a small test program to check if P1 is taking the data.

MOV P1,#0FFH ;config as input MOV P0,#00H ;SELECT CHANNEL 0 LOOP: MOV A,P1 ; READ CONTENTS FROM P1 MOV P3,A ;SEND TO P3 ACALL DELAY SJMP LOOP

After running this program P3 remains FFh all the time. The data is arriving correctly at the input port, double checked with multimeter.

1. I've configured P1 as input, MOV P1,#0FFH. did not forget that..

2. I'm using a 220V AC to 5V DC adaptor, current rating is 500mA.

3. The clock to the ADC0809 is 100KHZ and is generated from the controller itself P2.0

4. To check if Port1 is working fine I connected few pins of P1 to VCC through 1k resistor and others to GND and ran the same program. IT WORKS FINE THAT TIME. P3 contains same data as P1. Then how come data from the adc is not read!!!!

I've thought of all possible problems. Looking at it from a logical standpoint it should and must work. Everything seems to be fine.

I would greatly appreciate help in this matter.

Parents Reply Children
  • you are evidently using P0 as output, do you have pullup resistors on it?

    Is the ADC 'free running' I see no comversion start commwnd in the loop?

    from the datasheet The address is latched into the decoder on the low-to-high transition of the address latch enable signal.
    I see nowhere that goes high.

    Also I am quite certain that your first read wil happen before the conversion is complete, I see no test of "end of conversion".

    I take it you have tied the ADC output enable pin to constantly enable output.

    anyhow

           MOV A,P1          ; READ CONTENTS FROM P1
           MOV P3,A          ;SEND TO P3
    

    WILL unconditionally copy whatever there is on P1 to P3 (could be written mov p3,p1)

    Erik

  • hi erik,
    first of all, thanks for your time.

    yes, it is in free running mode as I've mentioned above. I've tied SOC with EOC(interrupt), so the negative going pulse from EOC should drive the SOC hence initiating the next conversion.

    Also the RD or OE is tied to Vcc (its always enabled)

    Anyway, the ADC is working fine.. I checked the output values of the adc, as I change the potentiometer (which varies the input voltage to ADC 'Vin') The output of ADC varies from "00000000" to "11111111". I've also checked for specific values, like for an input voltage of 2.5V the corresponding output is 7Fh, so that has convinced me that ADC is doing its job.

    As to why 89c51 is not taking the data is what I can't understand.

    1. is the current drive not enough? have you or anyone else for that matter used a buffer between ADC and the Port P1?

    2. are the two IC's adc 0809 and 89C51 compatible?

    The controller is in a continuous loop, copying contents of P1 to P3. so as I vary the potentiometer P3 values should change appropriately, which doesn't happen. P3 is fixed at FFh..

  • Anyway, the ADC is working fine.. I checked the output values of the adc
    have you checked it at P1?

    is the current drive not enough?
    CMOS takes microamperes and you state thet your uC has a C in the number.

    have you or anyone else for that matter used a buffer between ADC and the Port P1?
    I can not say no, but it would not make sense if they are on the same board

    are the two IC's adc 0809 and 89C51 compatible?
    two things to check
    voltages
    timing
    but without checking the above I'd say they are. However I will ALWAYS check both timing and Vih Vil Voh and Vol before connecting 2 chips.

    Erik

    PS if you, at any time had P1 set low while the ADC was working, it is likely that you burned the port