Go Down

Topic: DACC register default value of Arduino Due (Read 883 times) previous topic - next topic

I got the way to sent the default value of ADC_MR to serial port using the code as following

  unsigned long reg;
  reg = REG_ADC_MR;
  Serial.print("REG_ADC_MR = ");
  Serial.println(reg, HEX);

And the default value is "REG_ADC_MR = 103C0100", which is great.
However, when I want to get the default value of DACC_MR using the similar code:

  unsigned long reg;
  reg = REG_DACC_MR;
  Serial.print("REG_DACC_MR = ");
  Serial.println(reg, HEX);

I can only get the result "REG_DACC_MR = 0", I checked the data sheet of SAM3X, I think there is something wrong with the default value 0. Since I think the "REFRESH
" byte cannot be 0, otherwise the DACC won't work. So there should be something wrong with my code to get the default value. Does anyone has some experience on that? How to get the default value of arbitrary register of SAM3X?

jt6245

when reset, DACC_MR=0x0
After using analogWrite, DACC_MR=0x10000800
This is what I got, you may follow the steps in analogWrite for detail.

#2
Jul 30, 2013, 12:14 pm Last Edit: Jul 30, 2013, 12:59 pm by diegozeng Reason: 1

when reset, DACC_MR=0x0
After using analogWrite, DACC_MR=0x10000800
This is what I got, you may follow the steps in analogWrite for detail.


Thank you! I got the same result by using "analogWrite()", but how can I change the default value of DACC_MR, for example, I wanted to make the refresh time shorter, I tried to modify the value of DACC_MR as following:
Code: [Select]

int reg;
int tsig[] = {500,1000,1500,2000,2500,3000,3500,4000};
void setup()
{
//DACC->DACC_MR = 10000400;(1)
analogWriteResolution(12);
Serial.begin(115200);
}
void loop()
{
//DACC->DACC_MR = 10000400;(2)
for(int i  = 0;  i  < 8; i++)
    analogWrite(DAC0, tsig[i]);
reg=REG_DACC_MR;
Serial.println(reg,HEX);
delay(100);
}

when I put 'DACC->DACC_MR = 10000400' at (1), it still appears "10000800" on serial monitor, when I put 'DACC->DACC_MR = 10000400' at (2), it appears "9810" on serial monitor, which is very strange and not meet my expection. It seem that the value of "DACC_MR" will change according to the instruction "analogWrite". But how can I modify its value to decrease the refreshing time of DAC?

jt6245

It is better to put 0x before 10000400 which indicates hex number.
Usually analogWrite will set DACC_MR  the first time use.
I don't think so -------- :smiley-surprise: "I think the "REFRESH
" byte cannot be 0, otherwise the DACC won't work."

Go Up