Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

serial Interfacing ad7321 with 8051

Status
Not open for further replies.

electronics32

Newbie level 2
Newbie level 2
Joined
Jul 18, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
15
I am trying to interface AD7321 with Microcontroller 8051. This is the code i came up with referring to the datasheet. Please tell me what is wrong with it.
#include<reg51.h>
sbit CS=P0^0;
sbit SCLK=P0^1;
sbit DIN=P0^2;
sbit DOUT=P0^3
sbit MSB=ACC^7;
sbit LSB=ACC^0;
void main(void)
{
unsigned char ranreg=
unsigned char ctrlreg=
unsigned char x;
while(1)
{
ACC=rangereg;
CS=0;
for(x=0;x<17;x++)
{
sclk=1;
DIN=MSB;
DELAY();
SCLK=0;
DELAY();
ACC=ACC<<1;
}
ACC=ctrlreg;
for(x=0;x<17;x++)
{
sclk=1;
DIN=MSB;
DELAY();
SCLK=0;
DELAY();
ACC=ACC<<1;
}
for(x=0;x<17;x++)
{
SCLK=1;
DELAY();
SCLK=0;
DELAY();
}
for(x=0;x<17;x++)
{
SCLK=0;
DELAY();
SCLK=1;
DELAY();
LSB=DOUT;
ACC=ACC<<1;
}
CS=1;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top