Go Down

Topic: Controling DACC directly on DUE (Read 1 time) previous topic - next topic

masumi

I'm trying to control DACC on DUE.

A9 is connected to GND. Result shows that AD value is zero. good.
A10 is connected to 3.3V. Result shows that AD value is 0xfff. good.
A11 is connected to DAC0. Result doesn't show small AD value and big AD value. bad.

I am very pleasure if you put any advice. thanks.

Program and result are follows.

Code: [Select]
void setup() {
  Serial.begin(57600);
  // ADC
  pmc_enable_periph_clk(ID_ADC);
  ADC->ADC_CR =
    ADC_CR_SWRST |
    ADC_CR_START;
  ADC->ADC_MR =
    ADC_MR_TRGEN_DIS | // Starting a conversion is only possible by software
    ADC_MR_LOWRES_BITS_12 |
    ADC_MR_FREERUN_ON |
    ADC_MR_PRESCAL(1); // zero is not stable
  ADC->ADC_CHER =
    ADC_CHER_CH11 |
    ADC_CHER_CH12 |
    ADC_CHER_CH13;
  // DACC
  pmc_enable_periph_clk(ID_DACC);
#if 0
  DACC->DACC_CR =
    DACC_CR_SWRST;
  DACC->DACC_MR =
    DACC_MR_TRGEN_DIS | // DACC in free running mode
    DACC_MR_WORD_HALF | // Half-Word transfer
    DACC_MR_TAG_EN; // DACC_CDR[13:12] are used for channel selection of the first data and the 2 bits
  DACC->DACC_CHER =
    DACC_CHER_CH0 |
    DACC_CHER_CH1;
#else
  dacc_reset(DACC);
  dacc_disable_trigger(DACC);
  dacc_set_transfer_mode(DACC,0);
  dacc_enable_flexible_selection(DACC);
  dacc_enable_channel(DACC,0);
  dacc_enable_channel(DACC,1);
#endif
  char buf[80];
  sprintf(buf,"DACC_MR %08x",DACC->DACC_MR); Serial.println(buf);
}
void loop() {
  static uint32_t count;
#if 0
  DACC->DACC_CDR = (0 << 12) | count; // DAC0 ... PB15
  DACC->DACC_CDR = (1 << 12) | count; // DAC1 ... PB16
#else
  dacc_write_conversion_data(DACC,(0 << 12) | count);
  dacc_write_conversion_data(DACC,(1 << 12) | count);
#endif
  count += 0x100; count &= 0xfff;
  delay(1000);
  uint32_t cdr11 = ADC->ADC_CDR[11]; // AD11 ... PB18 ... A9
  uint32_t cdr12 = ADC->ADC_CDR[12]; // AD12 ... PB19 ... A10
  uint32_t cdr13 = ADC->ADC_CDR[13]; // AD13 ... PB20 ... A11
  char buf[80];
  sprintf(buf,"%08x %08x %08x %08x",count,cdr11,cdr12,cdr13); Serial.println(buf);
}

DACC_MR 00100000
0100 0000 0fff 02ad
0200 0000 0fff 0347
0300 0000 0fff 0400
0400 0000 0fff 04a0
0500 0000 0fff 0556
0600 0000 0fff 05f8
0700 0000 0fff 06a8
0800 0000 0fff 074e
0900 0000 0fff 07fc
0a00 0000 0fff 08a6
0b00 0000 0fff 0952
0c00 0000 0fff 09fc
0d00 0000 0fff 0aa8
0e00 0000 0fff 0b53
0f00 0000 0fff 0bfe
0000 0000 0fff 0ca9
0100 0000 0fff 02ad
0200 0000 0fff 034a
...


masumi

I found the topis about this issue.
http://forum.arduino.cc/index.php?topic=129765.msg988889#msg988889
Outputvoltage of DACC on DUE seems to be from 0.5V to 2.7V.
This must be limitation of SAM3X.


jt6245

It may be better to set refresh  in DAC_MR. I try your code( change dac0 output to 0X0 and dac1
output to 0xFFF),and get 0x29? and 0xd5? respectively.  Look like the thing (1/6 to 5/6 of ref voltage) you have mentioned.

masumi

thanks  jt6245,
I have tested a few REFRESH value. But There was alomost same.

jt6245

        I notice your sketch put one second delay after dac output. According to data sheet ( 45.6.7 DACC Timings), "After 20 ?s the analog voltage resulting from the converted data will start decreasing,.....".
I guess in here 20us should be 20ms,Because I saw AVR sample software put a  condition ---refresh*1024*1000/dac clock  <  20.
        I test the code with dac0 output=0x00 in column 3,dac1 output=0xFFF in column 4, under setting with refresh=0 and refresh=8.(see the attachment picture).
More voltage fluctuation see in the testing  with refresh=0.

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview