AD1674 with AT89C51
Discussion in "8051 Discussion Forum" started by sageliu Jun 10, 2016.
Fri Jun 10 2016, 08:58 pm
Hi all
Here is code of AD1674 with C51 convert.
#include <reg51.h>
#include <INTRINS.H>
#include <STDIO.H>
sbit STATUS = P1^0;
unsigned char xdata CTRL _at_ 0x2FFF; //Why define CTRL at the external Address?
unsigned char xdata ADSEL _at_ 0x4FFF; //Why define ADSEL at the external Address?
unsigned char hByte;
unsigned char lByte;
void adc_Convert (void)
{
CTRL = 0x00; //Why assign 0x00 to the address? And What delegated for the CTRL?
ADSEL = 0x00; //Why assign 0x00 to the address?
while(STATUS==1);
CTRL = 0x02; //Why assign 0x02 to the address?
hByte = ADSEL;
CTRL = 0x03; //Why assign 0x03 to the address?
lByte = ADSEL;
}
void main(void)
{ unsigned int delay, MSB , LSB, adc_Res;
SCON = 0xDA;
TMOD |= 0x20;
TH1 = 0xFD;
TR1 = 1;
TI = 1;
while(1)
{
adc_Convert();
MSB=(unsigned int)(hByte << 4);
LSB=(unsigned int)(lByte >> 4);
adc_Res = MSB + LSB;
printf("ADC READINGS: %03Xh\n", adc_Res);
for (delay=0; delay<10000; delay++)
;
}
}
Please explain detail for me ,thanks for your help in advance!!
Here is code of AD1674 with C51 convert.
#include <reg51.h>
#include <INTRINS.H>
#include <STDIO.H>
sbit STATUS = P1^0;
unsigned char xdata CTRL _at_ 0x2FFF; //Why define CTRL at the external Address?
unsigned char xdata ADSEL _at_ 0x4FFF; //Why define ADSEL at the external Address?
unsigned char hByte;
unsigned char lByte;
void adc_Convert (void)
{
CTRL = 0x00; //Why assign 0x00 to the address? And What delegated for the CTRL?
ADSEL = 0x00; //Why assign 0x00 to the address?
while(STATUS==1);
CTRL = 0x02; //Why assign 0x02 to the address?
hByte = ADSEL;
CTRL = 0x03; //Why assign 0x03 to the address?
lByte = ADSEL;
}
void main(void)
{ unsigned int delay, MSB , LSB, adc_Res;
SCON = 0xDA;
TMOD |= 0x20;
TH1 = 0xFD;
TR1 = 1;
TI = 1;
while(1)
{
adc_Convert();
MSB=(unsigned int)(hByte << 4);
LSB=(unsigned int)(lByte >> 4);
adc_Res = MSB + LSB;
printf("ADC READINGS: %03Xh\n", adc_Res);
for (delay=0; delay<10000; delay++)
;
}
}
Please explain detail for me ,thanks for your help in advance!!
[ Edited Fri Jun 10 2016, 09:06 pm ]
Sat Jun 11 2016, 10:38 am
Where did you taken this code ?
Can you share the schematic where this code is implemented ?
--
Karan
Can you share the schematic where this code is implemented ?
--
Karan
Sat Jun 11 2016, 08:13 pm
Where did you taken this code ?
Can you share the schematic where this code is implemented ?
--
KaranKaran123
Hi Karan
I don't upload photo of schematic,here is link for other website for your reference.
http://www.edaboard.com/thread355629.html
[ Edited Sat Jun 11 2016, 08:14 pm ]
Powered by e107 Forum System