#include <REGX51.H>
#include "lcd.h"
#include "adc.h"
void main(){ unsigned char a = 0;
P2 =0x00;
P0 =0x00;
P1 = 0xff;
P3 = 0x00;
lcd_init();
lcd_cmd(0x80);
lcd_data(54); // just send "1" to lcd to display ;
string("t");
lcd_cmd(0xc0);
conv(); //Start conversion
read(); //Read ADC
P3 = P1;
lcd_data(a);
while(1);
}
Proteus file attached .
Code C - [expand] 1 conv() and read()
#define cs P0_0
#define rd P0_1
#define wr P0_2
#define intr P0_3
void conv(); //Start of conversion function
void read(); //Read ADC function
unsigned char adc_val;
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 = 1; //Make RD low
adc_val = P1;
rd = 0; //Make RD high
cs = 1; //Make CS high
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?