My first run with ADUC842

Today I got a ADUC development board in our store, so I started with my task, the same task sinewave generation, reading back the sinewave and saving the sinewave samples in external ram(actually the xram is inside the chip, but it is interfaced as external). There was a crystal attached to the chip . but the crystal attached to the chip was not active by default. The system clock is decided by a internal PLL circuit and is controlled by CONFG842 sfr.

Sinewave generation with the DAC0

I had taken 6 samples per cycle which was not enough(which was simulated accurate sinewave in proteus). So I had to increase the sample rate to 36 per cycle(10 degree interval). Rest job was to read the sinewave .

Reading Sinewave normal and DMA mode

Using adc with ADUC is a bit complex at software part and simple at hardware, because you have to configure 3 sfr’s ADC1-3. The data will be written at ADCDATAH and ADCDATAL two 8bit registers. Actually ADCDATAH contains the ADC channel id at the higher 4 bit locations and the higher 4 bit of the ADCread value at the lower 4 cells. Save both the values in an integer variable.

Saving the data in RAM

The adcread values need to b saved at some location for further processing. This is better with some external RAM(XRAM), fortunately we have 2KB of external ram inside the microcontroller.

Signal processing

Perhaps this is the last job that I have to do for my thesis, I need some FFT calculation to get the impedance value from the samples read by ADC.

Is it simple

This is all I have to do for now. From the first stage to the last stage there are a lot of hidden problems. Getting a pure sinewave at a high frequency wwith tradeoff between frequency and sinewave shape…

ADC DAC External Memory(RAM)

This is what I am assigned to do, what are the aim

  • Generate Sinewave through DAC (why not PWM?)
  • Read the sinewave(through ADC810)
  • Save the values in a 32KB Ram.

And the tradeoffs are

  • Generate the highest frequency which will lead to impure sinewave.
  • DAC and ADC speed must match.
  • Simultaneously i have to save the data in RAM

 
 

The microcontroller U5 (AT89C51) is generating sinewave, loaded with the following code

#include<reg51.h>

void delay(int k)

{int i,j=k*10;

for(i=0;i<j;i++)

{}

}

main()

{

while(1)

{

    /*

P1=0x01;delay(5000);

P1=0x00;delay(5000);

P1=0x80;delay(5000);

P1=0x00;delay(5000);

*/

// P1=0x80; //delay(3); //10

// P1=0x96;//delay(3); //20

//P1=0xAB;//delay(3); //30

// P1=0xC0; //delay(3);     //40

// P1=0xD2; //delay(3); //50

P1=0xE2;    //delay(3);     //60

// P1=0xEE;    //delay(3);        //70

// P1=0xF8; //delay(3);    //80

//P1=0xFE; //delay(3); //90

//P1=0xFF; //delay(3);         //100

//P1=0xFE;     //delay(3);

P1=0xF8;    //delay(3);          //120

 

//P1=0xEF; //delay(3);

//P1=0xE2;//delay(3);

//P1=0xD2;//delay(3);         //150

//P1=0xC0; //delay(3);

// P1=0xAB; //delay(3);

P1=0x96;    //delay(3);         //180

//P1=0x80;    //delay(3);

//P1=0x69; //delay(3);

//P1=0x54; //delay(3);         //210

//P1=0x40; //delay(3);

//P1=0x2D;     //delay(3);

P1=0x1D;    //delay(3);     //240                

//P1=0x11;//delay(3);

//P1=0x07;//delay(3);

//P1=0x01; //delay(3);     //270

//P1=0x00; //delay(3);

//P1=0x01;    //delay(3);

P1=0x07;    //delay(3);     //300

//P1=0x11; //delay(3);

//P1=0x1D;//delay(3);

//P1=0x2D;//delay(3);     //330

// P1=0x40; //delay(3);

// P1=0x54; //delay(3);

P1=0x69;    //delay(3);     //360

 

                            

     /*

     P1=0x80;

     P1=0xC0;

     P1=0xEE;

     P1=0xFF;

     P1=0xEE;

     P1=0xC0;

     P1=0x80;

     P1=0x40;

     P1=0x11;

     P1=0x00;

     P1=0x11;

     P1=0X40;

     */

}

}

And the U1 doing 2 jobs one is to read the sinewave through a ADC810 and other is two save sinewave data to a external RAM 32KB. U1 loaded with following code