![]() | ![]() | ![]() |
| |||||||
| 8051/8951 A specify forum for the Intel 8051/8951 single chip microcontroller. |
![]() |
| | Tools |
| | #1 |
|
I have to interface AdC 0809 to 8051 in my project. Can anyone give me the programming code for ADC interfacing to 8051?
| |
| |
| | #2 |
|
First make clear, how many AD channels you want. As ADC0808/9 is having 8 channels, meaning you can input 8 different analog inputs and select any one of them at any time with the help of onchip mux. If you want to scan a single analog input, then use ADC0801. Everything is given in the datasheet regarding connecting ADC with uC etc. Anyway you simply ground the chip select pin (CS) of ADC, connect the read(start) pin and write pin to uC. Connect the INTR pin of ADC to INT1 pin of uC (8051) and the data of ADC to any port of your interrest (Precaution with P0 is you need to give pull ups). This much is enough to interface ADC0801. If using ADC0808/9, you need to give select lines from uC to ADC. Program sequence will be. apply active low pulse at write pin of ADC wait till interrupt comes. write ISR for hardware interrupt 1 as follows. apply active low pulse at read pin of ADC read the port. Lastly, you will get everything regarding ADC0801 here. http://www.google.co.in/search?sourc...D:en&q=ADC0801
__________________ Microcontroller codes, schematics, and diagrams! | |
| |
| | #3 |
|
This ADC is designed to be memory mapped. You can connect it to the external memory bus on your 8051. The MOVX instruction can be used to read and write to the ADC. Just connect RD,WR and DB0-7 to the coresponding 8051 bus pins. You can pick an Address pin (AD8-15) and connect it to CS. When you do a MOVX to a memory location that sets that address pin high the write or read will go to the ADC. Your code then becomes one instruction: MOVX A, @DPTR to read the ADC through the bus. | |
| |
| | #4 |
|
clr p3.6 setb p3.6 clr p3.6 mov p0,10100000b setb p3.7 clr p3.7 setb p3.7 setb p1.7 clr p1.7 setb p1.6 herr: jb p1.6,herr setb p3.6 mov p2,#11111111b mov r5,p2 ;------------------------------ to 0809 p3.7 to ale ((adress lach eneble) p3.6 to oe (out eneble) p1.7 to start : idea: p1.6 to eoc p0 canect to 0809 adress (abc) :idea: | |
| |
| | #5 |
|
give me the ckt of the interfacing of microcontroller and analog to digital converter
| |
| |
| | #6 | |
| Quote:
Hope you have find the solution, if not then my code might help you Code: ;=========================================================
; Pin Definations
;=========================================================
adc_data_bus equ 90h ; Port 0
adc_add_a equ b4h ; P3.4
adc_add_b equ b3h ; P3.3
adc_ale_soc equ b5h ; P3.5
adc_eoc equ b6h ; P3.6
adc_oe equ b7h ; P3.7
;=========================================================
; Main Program starts from here
;=========================================================
adctemp: clr adc_add_a ; Channel 0 is ie Temp is selected
clr adc_add_b ;Add b = 0, Add a = 0
nop
setb adc_ale_soc ;ale and soc is made high
nop
nop
nop
nop
clr adc_ale_soc ;ale and soc is made low
jb adc_eoc,$ ;check for eoc
jnb adc_eoc,$ ;check for eoc
setb adc_oe ;if eoc high,make oe high
nop
nop
nop
mov a,adc_data_bus ;Read port0 data to accumulator
mov 40h,a ;Copy this data in 40h for furher processing
clr adc_oe ;make oe low
ret
;=========================================================;
Program ENDS here
;========================================================= Last edited by rushi53; 15th October 2009 at 07:07 AM. Reason: ALE and SOC pins of ADC should be shorted | ||
| |
|
| Tags |
| 0809, 8051, adc, interfacing |
| Thread Tools | |
| Display Modes | |
| |