[SAMD51] DAC Configuration

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, 

 

We are using DAC in our project. We want to output a static voltage (0 - 0V, 4096 (0x0FFF) - 3.3V)on DAC channels. 

- 12 bit DAC resolution 
- 3.3 V reference (Unbuffered external voltage) 

 

Could you please help with configuring DAC for our project? 

 

Also, please explain about refresh period, dithering mode and current control. Do i need to configure these options?  because in datasheet i am able to find below statment,

 

When a DAC is used to generate a static voltage or at a rate less than 20kSPS, the conversion must be refreshed periodically.

 

Blindly i Used below example, i am able to generate the sawtooth waveform,,

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

void DAC_0_example(void) 

        uint16_t i = 0; 
       dac_sync_enable_channel(&DAC_0, 0); 
       for(;;) { 
                       dac_sync_write(&DAC_0, 0, &i, 1); 
                      i = (i+1) % 1024; 
               } 
}

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

Jana8153

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Jana,

I'm using a SAME70Q21B on an XPLD board, and prefer to program on a rather low level (just using the info from the datasheet). At this level, configuring the DAC consists of

 

REG_PMC_WPMR = 0x504D4300;  //disabling write protection for PMC

   //configuring the PMC as needed

REG_PMC_PCER0 = 0x40000000;  //enabling the clock for DAC in PMC; plus ones for all other needed devices, of course

REG_PMC_PCR = 0x3000141E;  //enabling MCK for DAC

REG_PMC_WPMR = 0x504D4301;  //enabling write protection for PMC

REG_DACC_WPMR = 0x44414300;  //disabling write protection for DACC

REG_DACC_CHER = 1;  //enabling DACC channel 0

REG_DACC_WPMR = 0x44414301;  //enabling write protection for DACC

 

After that, writing the value of i into the data register looks like:

 

while((REG_DACC_CHSR & 0x100) == 0)  //waiting for channel 0 to become ready

{}

REG_DACC_CDR0 = i;

 

I modified the usual sawtooth test so that further output can be stopped by pressing a button, and the (arbitrary) output voltage remained stable for minutes (measured with a resolution of 1 mV).  So, I guess the DAC works in a static way.  Nevertheless, refreshing the output periodically might be a good idea if the output voltage has any critical function.

Hope this helps,

Joerg

Last Edited: Fri. Jan 4, 2019 - 08:18 PM