How to resolve the contention between 2 ADC0801!!!???
I would like using two ADC0801 in order to read 2 Vol electric signal ., 2 ADC interfaces with AT89c51 by using common input..If I use an ADC, no problem, but with 2 ADC ,ADC will not working!!!! Please help me!!!
My programmer and file Proteus is below
www.MegaShare.com/512261
i have already debuged my code C with Keil,run as normal,but it can't stimulate with PROTEUS, ,so i will write my code here,,help me to test my code please!!
this program use each button to read each ADC //button1=P2_6 //button2=P2_7
#include <REGX51.H> sbit ledD0=P0^0; sbit ledD1=P0^1; sbit ledD2=P0^2; sbit ledD3=P0^3; sbit ledD4=P0^4; sbit ledD5=P0^5; sbit ledD6=P0^6; sbit LED_0=P2^0; //hang don vi sbit LED_1=P2^1; //hang chuc sbit LED_2=P2^2; //hang tram sbit INTR_1=P3^2;//INTR0 of CHIP sbit INTR_2=P3^3;//INTR1 of CHIP sbit CS_1=P3^4; sbit CS_2=P3^5; long n; int a,b,c; void delay(long time) { for(n=0; n<time; n++) { ; } } void bit_dec() { c=P1%10;//hang don vi b=((P1-c)/10)%10;//hang chuc a=((((P1-c)/10)-b)/10)%10; //hang tram } unsigned char x; void Hienthiled(x) // Co 1 bien dau vao de xac dinh xem la hien thi so nao { int arr[]={64,121,36,48,25,18,2,120,0,16} ; P0 = arr[x]; } void inhangtram() { LED_2=0; LED_1=LED_0=1; Hienthiled(a); } void inhangchuc() { LED_1=0; LED_0=LED_2=1; Hienthiled(b); } void inhangdonvi() { LED_0=0; LED_1=LED_2=1; Hienthiled(c); } void laymauADC1() { //convert voi ADC1 CS_1=0; //Make CS low RD=1; WR=0; WR=1; CS_1=1; while(INTR_1==1); //Read ADC CS_1=0; //Make CS low RD = 0; //Make RD low RD = 1; //Make RD high CS_1=1; //Make CS high } void laymauADC2() { //convert voi ADC2 CS_2=0; //Make CS low RD=1; WR=0; WR=1; CS_2=1; while(INTR_2==1); //Read ADC CS_2=0; //Make CS low RD = 0; //Make RD low RD = 1; //Make RD high CS_2=1; //Make CS high } void phimbam() { if(P2_6==0){laymauADC1();} else if(P2_7==0){laymauADC2();} } void main(void) { while(1) { WR=1;// chuyen doi lai RD=1;// xoa gia tri da doc truoc do phimbam(); bit_dec(); inhangtram(); delay(3000); inhangchuc(); delay(3000); inhangdonvi(); delay(3000); } }
if you want to see schema you can see here www.mediafire.com/
Please read the instructions on how to post source code - they are really quite clearly stated: www.danlhenry.com/.../keil_code.png
Note that TABs don't work (well) - use spaces instead,
and don't forget to check it in the 'Preview'...
If you can miss such obvious details when just posting on a forum, you're going to have reall difficulties with embedded development...
wow! cool! remarks in mandarin (I think) !