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.

Coding for MAX1112 with 8051 based on Keil C-compiler

Status
Not open for further replies.

mymadi

Newbie level 6
Joined
Sep 20, 2006
Messages
11
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,345
anyone can help me to do some coding on max1112 with 8051 based on keil c-compiler?

// Coding for MAX1112 (Serial ADC)
#include <reg51.h>

sbit CS1 = P1^0;
sbit SCLK1 = P1^1;
sbit DIN1 = P1^2;
sbit DOUT1 = P1^3;
sbit LSBRA = ACC^0;
sbit MSBRA = ACC^7;



void Delay (unsigned int msec);
void Sending (void);
void Reading (void);

void main ()
{
while (1)
{
Sending ();
Reading ();
}
}

void Sending ()
{
unsigned char x;
unsigned char conbyte = 0x9E; // Channel 1

ACC = conbyte;
CS1 = 0;
for (x = 0; x < 8; x++)
{
SCLK1 = 0;
DIN1 = MSBRA;
Delay (2);
SCLK1 = 1;
Delay (2);
ACC = ACC << 1;
}
CS1 = 1;
SCLK1 = 0;
}

void Reading ()
{
unsigned char x;
CS1 = 0;
SCLK1 = 1;
//Delay (2);//
SCLK1 = 0;
Delay (2);

for (x = 0; x < 8; x++)
{
SCLK1 = 1;
//Delay (2);//
SCLK1 = 0;
Delay (2);
LSBRA = DOUT1;
ACC = ACC << 1;
}

CS1 = 1;
P0 = ACC;
}

// Delay
void Delay (unsigned int msec) // Delay
{
unsigned int i;

TMOD = 0x01; // Timer 0 Mode 1 (16 Bit)

for (i = 0; i < msec; i++) // mili seconds
{
TH0 = 0xFF; //FC
TL0 = 0xFE; // 17
TR0 = 1; // Turn ON T0
while (TF0 == 0); // Wait for TF0 to roll over
TR0 = 0; // Turn OFF T0
TF0 = 0; // Clear TF0
}
}
 

Re: MAX1112 and 8051

At first glance, you use ACC (Accumulator) inside C loop, you can't do that!

Please change ACC with other normal variable.
 

Re: MAX1112 and 8051

budhy said:
At first glance, you use ACC (Accumulator) inside C loop, you can't do that!

Please change ACC with other normal variable.

Thank you for your advice.. i will try... :D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top