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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/08/04 06:42
Read: times


 
#78985 - RE: DAC doesn\'t work well.
Responding to: ???'s previous message
Thanks everyone.
Current my code is here.
The DAC system started working but it still doesn't work correctly.

Serial data (8-N-1, 9600bps) comes from another ADuC814.

For receiving separeted 12bits digital date serially (0000XXXX for high 4bits and XXXXXXXX for low 8bits) from SBUF, I could write the following code.

What I have to do is to make a confirmation that now receiving data is High or Low. I pick up the first 5 even number of data and if these all are 0000XXXX, then this even part is high byte and the next one should be low byte XXXXXXXX. Accurate rate is 1-(1/16)^5 = 99.9999%. When these 5 don't match the state of high byte, then these are all low byte and high byte comes next.

After judgement is over, DAC should work without any problems but... in this case it doesn't so much well.
DAC0 pin outputs quite a different shape of wave. Any problems?

--------------------------------------------------
#include <stdio.h>
#include <ADuC814.h>

void daouth(int i) {  // update high byte
 DAC0H = i;
}

void daoutl(int i) {  // update low byte
 DAC0L = i;
}

void main(void) {
 int i, a[5];
 ADCCON1 = 0x80;  // turn on the internal reference
 DACCON = 0x0D; // DAC outputs update as soon as the DAC low byte are written.
 DAC0H = 0x00; // initialize DAC high byte
 DAC0L = 0x00; // initialize DAC low byte
 SCON = 0x52;  // 8bits UART, enable serial receive
 TMOD = 0x22;  // 8bits auto-reload timer/counter
 TH1 = 0xF7;   // F7 for 9600 band
 TR1 = 1;      // run timer1
 PCON = 0x80;  // double UART baud rate

 while(1) {
  i = 0;
  while(i<10) {
   if(RI) {
    if(!(i%2)) a[i/2] = SBUF;
    i++;
    RI = 0;
   }
  }
  if(a[0]&0x0F==a[0] && a[1]&0x0F==a[1] && a[2]&0x0F==a[2] && a[3]&0x0F==a[3] && a[4]&0x0F==a[4]) {
   while(1) {
    if(RI) {
     P1 ^= 0x02;
     daouth(SBUF);
     RI = 0;
    }
    if(RI) {
     P1 ^= 0x02;
     daoutl(SBUF);
     RI = 0;
    }
   }
  }
  else {
   while(1) {
    if(RI) {
     P1 ^= 0x02;
     daoutl(SBUF);
     RI = 0;
    }
    if(RI) {
     P1 ^= 0x02;
     daouth(SBUF);
     RI = 0;
    }
   }	
  }
 }
}

--------------------------------------------------


List of 8 messages in thread
TopicAuthorDate
DAC doesn't work well.            01/01/70 00:00      
   RE: DAC doesn't work well.            01/01/70 00:00      
   RE: DAC doesnt work well.            01/01/70 00:00      
   RE: DAC doesn't work well.            01/01/70 00:00      
   RE: DAC doesn\'t work well.            01/01/70 00:00      
      Serial transmission + output filter            01/01/70 00:00      
      RE: DAC doesn\\\'t work well.            01/01/70 00:00      
         RE: DAC doesn\\\\\\\'t work well.            01/01/70 00:00      

Back to Subject List