Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/11/09 14:35
Read: times


 
#168315 - RAM write and read
I am working with the Aduc812 (8051). For my project I want to write some data into the RAM.
The initialising of the RAM should look like this:

unsigned char xdata array[100];

Here is the code for reading and printing 8 A/D channels, where the data buffer should be filled with.

#include <ADUC812.H>
#include <stdio.h>
#include <math.h>

void main (void)
{
unsigned char chan_2_convert;

/*-----------------------------------------------
Configure the serial port to run at 9600 Baud.
-----------------------------------------------*/

TMOD |= 0x20;
TH1 = 0xFD;
TR1 = 1;
PCON &= 0x7F;
SCON = 0x52;
/*-----------------------------------------------
Configure the A/D to sequentially convert each
input channel.
-----------------------------------------------*/
ADCCON1 = 0x7C;

while (1)
{
unsigned int conv_val;
unsigned char channel;

/*-----------------------------------------------
Start a conversion and wait for it to complete.
-----------------------------------------------*/
chan_2_convert = (chan_2_convert + 1) % 8;
ADCCON2 = (ADCCON2 & 0xF0) | chan_2_convert;
SCONV = 1;
while (ADCCON3 & 0x80);

/*-----------------------------------------------
Read A/D data and print it out.
-----------------------------------------------*/
channel = ADCDATAH >> 4;
conv_val = ADCDATAL | ((ADCDATAH & 0x0F) << 8);
printf ("%bu %04drn ", channel,conv_val);


Job: All data of the 8 channels should be written into the RAM xdata.
Maybe someone has an idea?
THX
Walter


List of 2 messages in thread
TopicAuthorDate
RAM write and read            01/01/70 00:00      
   I do not know your chip, but typically ...            01/01/70 00:00      

Back to Subject List