Programming 8051 Microcontroller

Assembly Programming for ADC0804

	rd equ P1.0           ;Read signal P1.0
wr equ P1.1 ;Write signal P1.1
cs equ P1.2 ;Chip Select P1.2
intr equ P1.3 ;INTR signal P1.3

adc_port equ P2 ;ADC data pins P2
adc_val equ 30H ;ADC read value stored here

org 0H
start: ;Start of Program
acall conv ;Start ADC conversion
acall read ;Read converted value
mov P3,adc_val ;Move the value to Port 3
sjmp start ;Do it again

conv: ;Start of Conversion
clr cs ;Make CS low
clr wr ;Make WR Low
setb wr ;Make WR High
setb cs ;Make CS high
jb intr,wait ;Wait for INTR signal
ret ;Conversion done

read: ;Read ADC value
clr cs ;Make CS Low
clr rd ;Make RD Low
mov a,adc_port ;Read the converted value
mov adc_val,a ;Store it in local variable
setb rd ;Make RD High
setb cs ;Make CS High
ret ;Reading done

Programming 8051 in C for ADC0804

#include <REGX51.H>     
#define adc_port P2 //ADC Port
#define rd P1_0 //Read signal P1.0
#define wr P1_1 //Write signal P1.1
#define cs P1_2 //Chip Select P1.2
#define intr P1_3 //INTR signal P1.3

void conv(); //Start of conversion function
void read(); //Read ADC function

unsigned char adc_val;

void main() {
while (1) { //Forever loop
conv(); //Start conversion
read(); //Read ADC
P3 = adc_val; //Send the read value to P3

void conv() {
cs = 0; //Make CS low
wr = 0; //Make WR low
wr = 1; //Make WR high
cs = 1; //Make CS high
while (intr); //Wait for INTR to go low

void read() {
cs = 0; //Make CS low
rd = 0; //Make RD low
adc_val = adc_port; //Read ADC port
rd = 1; //Make RD high
cs = 1; //Make CS high

This finishes our ADC tutorial along with interfacing of ADC0804. If you have any questions or doubts please post on forum.


Mon Oct 20 2014, 11:22 AM
@skrishna, please post in forum so we can help you better.
Tue Oct 14 2014, 01:45 PM
how do i write an ALP equivalent 7segment display interfacing embedded c program (both 8051 microcontroller)
Sat Oct 11 2014, 06:41 PM
want details of seven segment LED display common cathode ( IC CD 4026)
Fri Oct 03 2014, 12:52 PM
Rickey you inspired me a lot ... I am also planing like you ...
Wed Oct 01 2014, 09:33 PM
We're back.. we had a bug, but posting is back to normal
Sat Sep 13 2014, 04:34 PM
jaimin1212,Pimpalkhare Create a thread for your question
Sat Sep 13 2014, 06:35 AM
i want to make self balancing robot using MPU6050 using atmega8.. please help to get data of gyro and accelerometer from this sensor through atmega8.
Thu Sep 11 2014, 01:00 PM
Sunil Pimpalkhare
Hello sir, I am trying to make Wearfin project so can u help me in teaching how to built the program???
Thu Sep 11 2014, 06:21 AM
hariom panday
plz hlp me in my project
Tue Sep 09 2014, 05:19 AM



Sun Oct 19 2014, 01:56 PM
Thu Oct 16 2014, 08:48 AM
Tue Oct 14 2014, 06:23 PM
Mon Oct 13 2014, 05:48 AM
Mon Oct 13 2014, 02:47 AM
Sun Oct 12 2014, 12:20 PM
Fri Oct 10 2014, 05:15 AM
Thu Oct 09 2014, 03:58 AM


Guests: 33, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37531
Newest member: pddung93
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Oct 22 2014, 03:22 AM
Okay, it seems to be a simple serial connection.Th...
jona Avatar
Posted By jona
Tue Oct 21 2014, 10:29 PM
I found this slightly different data sheet on a pu...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:35 PM
after this Accept-language:en-us\r\n...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:33 PM
@ aksharAT89C51AC3 can bebut the final decision wi...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:29 PM
@ Okechukwubefore starting this project you should...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:18 PM
@ kirangowleyou have to set the microphone level a...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:08 PM
i didnt understand the error where is error is th...
majoka Avatar
Posted By majoka
Tue Oct 21 2014, 06:04 PM
@ msidealMicrochip MCP23008 I2C 8-bit I/O expander...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Oct 21 2014, 05:21 PM
I found this slightly different data sheet on a pu...
msideal Avatar
Posted By msideal
Tue Oct 21 2014, 04:56 PM
Coding on Assembly Language is attached hereCODE:....