24. Digital-to-analog converter (DAC)

24.1 DAC introduction

The DAC module is a 12-bit, voltage output digital-to-analog converter. The DAC can be configured in 8- or 12-bit mode and may be used in conjunction with the DMA controller. In 12-bit mode, the data can be left- or right-aligned. The DAC features two output channels, each with its own converter. In dual DAC channel mode, conversions can be done independently or simultaneously when both channels are grouped together for synchronous update operations. An input reference pin, VREF+ (shared with other analog peripherals) is available for better resolution. An internal reference can also be set on the same input. Refer to voltage reference buffer (VREFBUF) section.

The DACx_OUTy pin can be used as general purpose input/output (GPIO) when the DAC output is disconnected from output pad and connected to on chip peripheral. The DAC output buffer can be optionally enabled to obtain a high drive output current. An individual calibration can be applied on each DAC output channel. The DAC output channels support a low power mode, the sample and hold mode.

24.2 DAC main features

The DAC main features are the following (see Figure 234: Dual-channel DAC block diagram ):

Figure 234 shows the block diagram of a DAC channel and Table 224 gives the pin description.

24.3 DAC implementation

Table 223. DAC features
DAC featuresDAC1
Dual channelX
Output bufferX
I/O connectionDAC1_OUT1 on PA4, DAC1_OUT2 on PA5
Maximum sampling time1 Msps
Autonomous mode (1)X
  1. 1. The autonomous mode is supported in Stop 1 mode.

24.4 DAC functional description

24.4.1 DAC block diagram

Figure 234. Dual-channel DAC block diagram

Figure 234. Dual-channel DAC block diagram. The diagram shows two DAC channels, Channel 1 and Channel 2, within a single block. Channel 1 is at the top, and Channel 2 is at the bottom. Both channels have their own 12-bit DAC converters, sample and hold registers, and buffers. Channel 1 includes offset calibration (OTRIM1), mode bits (MODE1), and data registers (DOR1). Channel 2 includes offset calibration (OTRIM2), mode bits (MODE2), and data registers (DOR2). Both channels have control registers and logic. External inputs include triggers (dac_ch1_trg1 to dac_ch1_trg15, dac_ch2_trg1 to dac_ch2_trg15), DMA signals (dac_ch1_dma, dac_ch2_dma), and hold clocks (dac_hold_ck). A 32-bit AHB bus is connected to the control registers. Power pins VDDA, VREF+, and VSS are shown. The diagram is labeled MSv74271V1.

The block diagram illustrates the internal architecture of a dual-channel DAC. It is divided into two main sections: DAC channel 1 (top) and DAC channel 2 (bottom).
DAC channel 1 consists of:
- Control registers & logic Channel1 : Receives inputs from a 32-bit AHB bus, dac_ch1_dma , dac_unr_it , dac_hclk , dac_ker_ck , and dac_hold_ck . It also contains TSEL1 [3:0] bits.
- Offset calibration : Includes OTRIM1[4:0] bits and MODE1 bits.
- DOR1 : A 12-bit data register.
- DAC converter 1 : A 12-bit converter that receives data from DOR1 and calibration bits.
- Buffer 1 : An output buffer for DAC converter 1 .
- Sample & Hold registers : Includes TSAMPLE1 , THOLD1 , and TREFRESH1 .
- Output: DACx_OUT1 (connected to Buffer 1 ) and TRIG (generated from TRIG input and TSEL1 ).
DAC channel 2 consists of:
- Control registers & logic Channel2 : Receives inputs from a 32-bit AHB bus, dac_ch2_dma , and dac_hold_ck . It also contains TSEL2 [3:0] bits.
- Offset calibration : Includes OTRIM2[4:0] bits and MODE2 bits.
- DOR2 : A 12-bit data register.
- DAC converter 2 : A 12-bit converter that receives data from DOR2 and calibration bits.
- Buffer 2 : An output buffer for DAC converter 2 .
- Sample & Hold registers : Includes TSAMPLE2 , THOLD2 , and TREFRESH2 .
- Output: DACx_OUT2 (connected to Buffer 2 ) and TRIG (generated from TRIG input and TSEL2 ).
The entire block is powered by VDDA (top), VREF+ (right), and VSS (bottom). The diagram is labeled MSv74271V1 in the bottom right corner.

Figure 234. Dual-channel DAC block diagram. The diagram shows two DAC channels, Channel 1 and Channel 2, within a single block. Channel 1 is at the top, and Channel 2 is at the bottom. Both channels have their own 12-bit DAC converters, sample and hold registers, and buffers. Channel 1 includes offset calibration (OTRIM1), mode bits (MODE1), and data registers (DOR1). Channel 2 includes offset calibration (OTRIM2), mode bits (MODE2), and data registers (DOR2). Both channels have control registers and logic. External inputs include triggers (dac_ch1_trg1 to dac_ch1_trg15, dac_ch2_trg1 to dac_ch2_trg15), DMA signals (dac_ch1_dma, dac_ch2_dma), and hold clocks (dac_hold_ck). A 32-bit AHB bus is connected to the control registers. Power pins VDDA, VREF+, and VSS are shown. The diagram is labeled MSv74271V1.
  1. 1. MODEx bits in the DAC_MCR control the output mode and allow switching between the normal mode in buffer/unbuffered configuration and the sample and hold mode.
  2. 2. Refer to Section 24.3: DAC implementation for channel2 availability.

24.4.2 DAC pins and internal signals

The DAC includes:

The DAC includes up to two separate output channels. Each output channel can be connected to on-chip peripherals such as comparator, operational amplifier and ADC (if available). In this case, the DAC output channel can be disconnected from the DACx_OUTy output pin and the corresponding GPIO can be used for another purpose.

The DAC output can be buffered or not. The sample and hold block and its associated registers can run in Stop mode using the LSI/LSE clock source (dac_hold_ck).

Table 224. DAC input/output pins

Pin nameSignal typeRemarks
VREF+Input, analog positive referenceThe higher/positive reference voltage for the DAC, \( V_{REF+} \leq V_{DDAmax} \) (refer to the product datasheet)
VDDAInput, analog supplyAnalog power supply
VSSAInput, analog supply groundGround for analog power supply
DACx_OUTyAnalog output signalDACx channely analog output

Table 225. DAC internal input/output signals

Internal signal nameSignal typeDescription
dac_ch1_dmaBidirectionalDAC channel1 DMA request/acknowledge
dac_ch2_dmaBidirectionalDAC channel2 DMA request/acknowledge
dac_ch1_trgx (x = 1 to 15)InputsDAC channel1 trigger inputs
dac_ch2_trgx (x = 1 to 15)InputsDAC channel2 trigger inputs
dac_unr_itOutputDAC underrun interrupt
dac_hclkInputDAC peripheral clock
dac_ker_ckInputDAC kernel clock
dac_hold_ckInputDAC low-power clock used in sample and hold mode
dac_out1Analog outputDAC channel1 output for on-chip peripherals
dac_out2Analog outputDAC channel2 output for on-chip peripherals

Table 226. DAC interconnection

Signal nameSourceSource type
dac_hold_ckck_lsi or ck_lseLSI or LSE clock selected in the RCC
dac_chx_trg1 (x = 1, 2)tim1_trgoInternal signal from on-chip timer
dac_chx_trg2 (x = 1, 2)tim2_trgoInternal signal from on-chip timer
dac_chx_trg3 (x = 1, 2)tim4_trgoInternal signal from on-chip timer
dac_chx_trg4 (x = 1, 2)ReservedInternal signal from on-chip timer
dac_chx_trg5 (x = 1, 2)tim6_trgoInternal signal from on-chip timer
dac_chx_trg6 (x = 1, 2)tim7_trgoInternal signal from on-chip timer
dac_chx_trg7 (x = 1, 2)tim8_trgo (1)Internal signal from on-chip timer
dac_chx_trg8 (x = 1, 2)tim15_trgoInternal signal from on-chip timer
dac_chx_trg11 (x = 1, 2)lptim1_ch1Internal signal from on-chip timer
dac_chx_trg12 (x = 1, 2)lptim3_ch1Internal signal from on-chip timer
dac_chx_trg13 (x = 1, 2)exti9External pin

1. This connection is only available on STM32U3B5/U3C5 devices.

24.4.3 DAC clocks

Two clock sources can be used to update the DAC:

The DAC clock is selected in the RCC.

24.4.4 DAC channel enable

Each DAC channel can be powered on by setting its corresponding ENx bit in the DAC_CR register. The DAC channel is then enabled after a \( t_{\text{WAKEUP}} \) startup time.

DACxRDY bit is set in the DAC_SR register when the DAC interface is ready to accept data. Writing new data or asserting the trigger is not allowed when ENx bit is set while DACxRDY signal is reset.

Note: The ENx bit enables the analog DAC channelx only. The DAC channelx digital interface is enabled even if the ENx bit is reset.

24.4.5 DAC data format

Depending on the selected configuration mode, the data have to be written into the specified register as described below:

Depending on the loaded DAC_DHRyyyx register, the data written by the user is shifted and stored into the corresponding DAC_DHRx (data holding registerx, which are internal non-memory-mapped registers). The DAC_DHRx register is then loaded into the DAC_DORx register either automatically, by software trigger or by an external event trigger.

Figure 235. Data registers in single DAC channel mode

Diagram showing the data register layout for single DAC channel mode. It consists of a 32-bit register (bits 31 to 0) with three rows representing different alignment modes. The first row shows 8-bit right alignment, where data is stored in bits 7:0. The second row shows 12-bit left alignment, where data is stored in bits 15:4. The third row shows 12-bit right alignment, where data is stored in bits 11:0. Shaded boxes indicate the active data bits for each mode.
31241570
8-bit right aligned
12-bit left aligned
12-bit right aligned

ai14710b

Diagram showing the data register layout for single DAC channel mode. It consists of a 32-bit register (bits 31 to 0) with three rows representing different alignment modes. The first row shows 8-bit right alignment, where data is stored in bits 7:0. The second row shows 12-bit left alignment, where data is stored in bits 15:4. The third row shows 12-bit right alignment, where data is stored in bits 11:0. Shaded boxes indicate the active data bits for each mode.

Depending on the loaded DAC_DHRyyD register, the data written by the user is shifted and stored into DHR1 and DHR2 (data holding registers, which are internal non-memory-mapped registers). The DHR1 and DHR2 registers are then loaded into the DAC_DOR1 and DOR2 registers, respectively, either automatically, by software trigger or by an external event trigger.

Figure 236. Data registers in dual DAC channel mode

Figure 236: Data registers in dual DAC channel mode. The diagram shows three rows of 32-bit registers with bit positions 31, 24, 15, 7, and 0 marked. Row 1 (8-bit right aligned) has bits 31-24 white, 23-15 white, 14-8 grey, and 7-0 dark grey. Row 2 (12-bit left aligned) has bits 31-20 grey, 19-15 white, 14-8 dark grey, and 7-0 white. Row 3 (12-bit right aligned) has bits 31-24 white, 23-12 grey, 11-8 white, and 7-0 dark grey. The label 'ai14709b' is in the bottom right corner.
Figure 236: Data registers in dual DAC channel mode. The diagram shows three rows of 32-bit registers with bit positions 31, 24, 15, 7, and 0 marked. Row 1 (8-bit right aligned) has bits 31-24 white, 23-15 white, 14-8 grey, and 7-0 dark grey. Row 2 (12-bit left aligned) has bits 31-20 grey, 19-15 white, 14-8 dark grey, and 7-0 white. Row 3 (12-bit right aligned) has bits 31-24 white, 23-12 grey, 11-8 white, and 7-0 dark grey. The label 'ai14709b' is in the bottom right corner.

Signed/unsigned data

DAC input data are unsigned: 0x000 corresponds to the minimum value and 0xFFF to the maximum value for 12-bit mode.

The DAC can also handle signed input data in 2's complement format. This is done by setting SINFORMATx bit in the DAC_MCR register.

When SINFORMATx bit is set, the MSB of the data written to DAC_DHRx registers is inverted when it is copied to the DAC_DORx register, and the DAC interface can accept signed data (Q1.15, Q1.11 or Q1.7 format). DAC_DHR12Lx register can be used to store 16-bit signed data in the data holding registers. The 12 MSBs of 16-bit data are used for the DAC output data and the MSB is inverted. The four LSBs are simply ignored.

Table 227. Data format (case of 12-bit data)

SINFORMATx bitDATA written to DAC_DHRx registerDATA transfered to DAC_DORx register
00x0000x000
00xFFF0xFFF
10x7FF0xFFF
10x0000x800
10xFFF0x7FF
10x8000x000

24.4.6 DAC conversion

The DAC_DORx cannot be written directly and any data transfer to the DAC channelx must be performed by loading the DAC_DHRx register (write operation to DAC_DHR8Rx, DAC_DHR12Lx, DAC_DHR12Rx, DAC_DHR8RD, DAC_DHR12RD or DAC_DHR12LD).

Data stored in the DAC_DHRx register are automatically transferred to the DAC_DORx register after one dac_hclk clock cycle, if no hardware trigger is selected (TENx bit in DAC_CR register is reset). However, when a hardware trigger is selected (TENx bit in DAC_CR register is set) and a trigger occurs, the transfer is performed three dac_hclk clock cycles after the trigger signal.

When DAC_DORx is loaded with the DAC_DHRx contents, the analog output voltage becomes available after a time \( t_{\text{SETTLING}} \) that depends on the power supply voltage and the analog output load.

To synchronize DAC and ADC, the same clock source can be used for both peripherals. This is done by selecting the dac_ker_ck clock instead of the dac_hclk clock (AHB clock) in the RCC.

HFSEL bits of DAC_MCR must be set when dac_ker_ck clock speed is faster than 80 MHz.

Refer to Table HFSEL description below for the limitation of the DAC_DORx update rate depending on HFSEL bits and dac_hclk or dac_ker_ck clock frequency.

If the data is updated or a software/hardware trigger event occurs during the non-allowed period, the peripheral behavior is unpredictable.

The above timing is only related to the limitation of the DAC interface. Refer also to the \( t_{\text{SETTLING}} \) parameter value in the product datasheet.

Table 228. HFSEL description

HFSEL [1:0]Clock frequencyLatency using AHB clock ( dac_hclk )Latency using dac_ker_ck clockFunction
00< 48 MHz34DAC_DOR update rate up to 3 AHB clock cycles or 4 dac_ker_ck cycles.
01\( \geq 48 \text{ MHz}^{(1)} \)55DAC_DOR update rate up to 5 AHB clock or dac_ker_ck cycles.
OthersReserved---

1. Refer to the device datasheet for the value of the maximum dac_hclk or dac_ker_ck frequency.

Figure 237. Timing diagram for conversion with trigger disabled TEN = 0

Timing diagram for conversion with trigger disabled (TEN = 0). The diagram shows three waveforms: Bus clock (a square wave), DHR (Digital Data Register), and DOR (Data Output Register). The DHR register is updated with the value 0x1AC. The DOR register is updated with the value 0x1AC. The output voltage available on the DAC_OUT pin is shown as a step function. The time interval between the DOR update and the output voltage settling is labeled t_SETTLING. The diagram is labeled MSV45319V2.
Timing diagram for conversion with trigger disabled (TEN = 0). The diagram shows three waveforms: Bus clock (a square wave), DHR (Digital Data Register), and DOR (Data Output Register). The DHR register is updated with the value 0x1AC. The DOR register is updated with the value 0x1AC. The output voltage available on the DAC_OUT pin is shown as a step function. The time interval between the DOR update and the output voltage settling is labeled t_SETTLING. The diagram is labeled MSV45319V2.

24.4.7 DAC output voltage

Digital inputs are converted to output voltages on a linear conversion between 0 and \( V_{\text{REF}+} \) .

The analog output voltage on the DAC channel pin is determined by the following equation:

\[ \text{DAC output} = V_{\text{REF}} \times \frac{\text{DOR}}{4096} \]

where all voltages are expressed in Volt.

24.4.8 DAC trigger selection

If the TENx control bit is set, the conversion can then be triggered by an external event (timer counter, external interrupt line). The TSELx[3:0] control bits determine which out of 16 possible events triggers the conversion as shown in TSELx[3:0] bits of the DAC_CR register. These events can be either the software trigger or hardware triggers.

Each time a DAC interface detects a rising edge on the selected trigger source (refer to the table below), the last data stored into the DAC_DHRx register are transferred into the DAC_DORx register. The DAC_DORx register is updated three dac_hclk cycles after the trigger occurs.

If the software trigger is selected, the conversion starts once the SWTRIG bit is set. SWTRIG is reset by hardware once the DAC_DORx register has been loaded with the DAC_DHRx register contents.

Note: TSELx[3:0] bit cannot be changed when the ENx bit is set.
When software trigger is selected, the transfer from the DAC_DHRx register to the DAC_DORx register takes only one dac_hclk clock cycle.

24.4.9 DMA requests

Each DAC channel has a DMA capability. Two DMA channels are used to service DAC channel DMA requests.

When an external trigger (but not a software trigger) occurs while the DMAENx bit is set, the value of the DAC_DHRx register is transferred into the DAC_DORx register when the transfer is complete, and a DMA request is generated.

In dual mode, if both DMAENx bits are set, two DMA requests are generated. If only one DMA request is needed, only the corresponding DMAENx bit must be set. In this way, the application can manage both DAC channels in dual mode by using one DMA request and a unique DMA channel.

As DAC_DHRx to DAC_DORx data transfer occurred before the DMA request, the very first data has to be written to the DAC_DHRx before the first trigger event occurs.

DMA underrun

The DAC DMA request is not queued so that if a second external trigger arrives before the acknowledgment for the first external trigger is received (first request), then no new request is issued and the DMA channelx underrun flag DMAUDRx in the DAC_SR register is set, reporting the error condition. The DAC channelx continues to convert old data.

The software must clear the DMAUDRx flag by writing 1, clear the DMAEN bit of the used DMA stream and re-initialize both DMA and DAC channelx to restart the transfer correctly. The software must modify the DAC trigger conversion frequency or lighten the DMA workload to avoid a new DMA underrun. Finally, the DAC conversion can be resumed by enabling both DMA data transfer and conversion trigger.

For each DAC channelx, an interrupt is also generated if its corresponding DMAUDRIEx bit in the DAC_CR register is enabled.

DMA double data mode

When the DMA controller is used in normal mode, only 12-bit (or 8-bit) data are transferred by a DMA request. As the AHB width is 32 bits, two 12-bit data may be transferred simultaneously. To use this mode, set the DMADOUbLE bit of DAC_MCR register.

A DAC DMA request is generated every two external triggers (except for software triggers) when the DMAENx bit is set:

  1. 1. When the first trigger is detected, the value of the DAC_DHRx and DAC_DHRBx registers are transferred into the DAC_DORx and DAC_DORBx registers. The actual DAC data is loaded into the DAC_DORx register. A DMA request is then generated. The DMA writes the new data to the DAC_DHRx and DAC_DHRBx data registers.
  2. 2. When the next trigger is detected, the actual DAC data is loaded into the DAC_DHRBx register. This second trigger does not generate any DMA request. The DORSTATx bit indicates which DOR data is actually loaded into the analog DAC input.

DMA underrun function is also supported in DMA double data mode.

The following conditions must be met to change from double data to single data mode or vice versa:

24.4.10 Noise generation

In order to generate a variable-amplitude pseudonoise, an LFSR (linear feedback shift register) is available. DAC noise generation is selected by setting WAVEx[1:0] to 01. The preloaded value in LFSR is 0xAAA. This register is updated three dac_hclk clock cycles after each trigger event, following a specific calculation algorithm.

Figure 238. DAC LFSR register calculation algorithm

Diagram of the DAC LFSR register calculation algorithm. It shows a 12-bit shift register with cells numbered 11 down to 0. The output of cell 0 is fed back through an XOR gate and also through a series of taps labeled X^12, X^6, X^4, X, and X^0. The output of the XOR gate is fed into cell 11. The outputs of cells 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and 0 are connected to a 12-bit wide NOR gate. The output of the NOR gate is also fed back to the input of cell 11. The diagram is labeled ai14713c.
Diagram of the DAC LFSR register calculation algorithm. It shows a 12-bit shift register with cells numbered 11 down to 0. The output of cell 0 is fed back through an XOR gate and also through a series of taps labeled X^12, X^6, X^4, X, and X^0. The output of the XOR gate is fed into cell 11. The outputs of cells 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and 0 are connected to a 12-bit wide NOR gate. The output of the NOR gate is also fed back to the input of cell 11. The diagram is labeled ai14713c.

The LFSR value, that may be masked partially or totally by means of the MAMPx[3:0] bits in the DAC_CR register, is added up to the DAC_DHRx contents without overflow and this value is then transferred into the DAC_DORx register.

If LFSR is 0x0000, a 1 is injected into it (antilock-up mechanism).

It is possible to reset LFSR wave generation by resetting the WAVEx[1:0] bits.

Figure 239. DAC conversion (SW trigger enabled) with LFSR wave generation

Timing diagram for DAC conversion with LFSR wave generation. The diagram shows four signals over time: Bus clock (a periodic square wave), DHR (Digital Hold Register, showing a value of 0x00), DOR (Digital Output Register, showing values 0xAAA and 0xD55), and SWTRIG (Software Trigger, showing a pulse). The DOR signal changes from 0xAAA to 0xD55 upon a SWTRIG pulse. The MSV45320V2 identifier is in the bottom right corner.
Timing diagram for DAC conversion with LFSR wave generation. The diagram shows four signals over time: Bus clock (a periodic square wave), DHR (Digital Hold Register, showing a value of 0x00), DOR (Digital Output Register, showing values 0xAAA and 0xD55), and SWTRIG (Software Trigger, showing a pulse). The DOR signal changes from 0xAAA to 0xD55 upon a SWTRIG pulse. The MSV45320V2 identifier is in the bottom right corner.

Note: The DAC trigger must be enabled for noise generation by setting the TENx bit in the DAC_CR register.

24.4.11 Triangle-wave generation

It is possible to add a small-amplitude triangular waveform on a DC or slowly varying signal. DAC triangle-wave generation is selected by setting WAVEx[1:0] to 10. The amplitude is configured through the MAMPx[3:0] bits in the DAC_CR register. An internal triangle counter is incremented three dac_hclk clock cycles after each trigger event. The value of this counter is then added to the DAC_DHRx register without overflow and the sum is transferred into the DAC_DORx register. The triangle counter is incremented as long as it is less than the maximum amplitude defined by the MAMPx[3:0] bits. Once the configured amplitude is reached, the counter is decremented down to 0, then incremented again and so on.

It is possible to reset triangle wave generation by resetting the WAVEx[1:0] bits.

Figure 240. DAC triangle wave generation

Graph of a triangle wave. The vertical axis represents the DAC output level, with labels for '0', 'DAC_DHRx base value', and 'MAMPx[3:0] max amplitude + DAC_DHRx base value'. The horizontal axis represents time. The waveform is a triangle wave oscillating between the base value and the maximum amplitude. The rising slope is labeled 'Incrementation' and the falling slope is labeled 'Decrementation'. The ai14715c identifier is in the bottom right corner.
Graph of a triangle wave. The vertical axis represents the DAC output level, with labels for '0', 'DAC_DHRx base value', and 'MAMPx[3:0] max amplitude + DAC_DHRx base value'. The horizontal axis represents time. The waveform is a triangle wave oscillating between the base value and the maximum amplitude. The rising slope is labeled 'Incrementation' and the falling slope is labeled 'Decrementation'. The ai14715c identifier is in the bottom right corner.

Figure 241. DAC conversion (SW trigger enabled) with triangle wave generation

Timing diagram showing Bus clock, DHR, DOR, and SWTRIG signals. The Bus clock is a square wave. DHR is set to 0xABE. DOR shows values 0xABE, 0xABF, and 0xAC0. SWTRIG is a pulse that triggers the conversion. The diagram illustrates the sequence of operations for triangle wave generation: DHR is loaded with 0xABE, SWTRIG is asserted, DOR becomes 0xABE, then SWTRIG is asserted again, DOR becomes 0xABF, then SWTRIG is asserted a third time, and DOR becomes 0xAC0.
Timing diagram showing Bus clock, DHR, DOR, and SWTRIG signals. The Bus clock is a square wave. DHR is set to 0xABE. DOR shows values 0xABE, 0xABF, and 0xAC0. SWTRIG is a pulse that triggers the conversion. The diagram illustrates the sequence of operations for triangle wave generation: DHR is loaded with 0xABE, SWTRIG is asserted, DOR becomes 0xABE, then SWTRIG is asserted again, DOR becomes 0xABF, then SWTRIG is asserted a third time, and DOR becomes 0xAC0.

Note: The DAC trigger must be enabled for triangle wave generation by setting the TENx bit in the DAC_CR register.

The MAMPx[3:0] bits must be configured before enabling the DAC, otherwise they cannot be changed.

24.4.12 DAC channel modes

Each DAC channel can be configured in normal mode or sample and hold mode. The output buffer can be enabled to obtain a high drive capability. Before enabling output buffer, the voltage offset needs to be calibrated. This calibration is performed at the factory (loaded after reset) and can be adjusted by software during application operation.

Normal mode

In normal mode, there are four combinations, by changing the buffer state and by changing the DACx_OUTy pin interconnections.

To enable the output buffer, the MODEx[2:0] bits in DAC_MCR register must be:

To disable the output buffer, the MODEx[2:0] bits in DAC_MCR register must be:

Sample and hold mode

In sample and hold mode, the DAC core converts data on a triggered conversion, and then holds the converted voltage on a capacitor. When not converting, the DAC cores and buffer are completely turned off between samples and the DAC output is tri-stated, therefore reducing the overall power consumption. A stabilization period, which value depends on the buffer state, is required before each new conversion.

In this mode, the DAC core and all corresponding logic and registers are driven by the LSI/LSE low-speed clock (dac_hold_ck) in addition to the dac_hclk clock, allowing using the DAC channels in deep low power modes such as Stop mode.

The LSI/LSE low-speed clock (dac_hold_ck) must not be stopped when the sample and hold mode is enabled.

The sample/hold mode operations can be divided into three phases:

  1. 1. Sample phase: the sample/hold element is charged to the desired voltage. The charging time depends on capacitor value (internal or external, selected by the user). The sampling time is configured with the TSAMPLEx[9:0] bits in DAC_SHSRx register. During the write of the TSAMPLEx[9:0] bits, the BWSTx bit in DAC_SR register is set to 1 to synchronize between both clocks domains (AHB and low speed clock) and allowing the software to change the value of sample phase during the DAC channel operation
  2. 2. Hold phase: the DAC output channel is tri-stated, the DAC core and the buffer are turned off, to reduce the current consumption. The hold time is configured with the THOLDx[9:0] bits in DAC_SHHR register
  3. 3. Refresh phase: the refresh time is configured with the TREFRESHx[7:0] bits in DAC_SHRR register

The timings for the three phases above are in units of LSI/LSE clock periods. As an example, to configure a sample time of 350 µs, a hold time of 2 ms and a refresh time of 100 µs assuming LSI/LSE ~32 KHz is selected:

In this example, the power consumption is reduced by almost a factor of 15 versus normal modes.

The formulas to compute the right sample and refresh timings are described in the table below, the Hold time depends on the leakage current.

Table 229. Sample and refresh timings

Buffer State\( t_{\text{SAMP}}^{(1)(2)} \)\( t_{\text{REFRESH}}^{(2)(3)} \)
Enable\( 7 \mu\text{s} + (10 * R_{\text{BON}} * C_{\text{SH}}) \)\( 7 \mu\text{s} + (R_{\text{BON}} * C_{\text{SH}}) * \ln(2 * N_{\text{LSB}}) \)
Disable\( 3 \mu\text{s} + (10 * R_{\text{BOFF}} * C_{\text{SH}}) \)\( 3 \mu\text{s} + (R_{\text{BOFF}} * C_{\text{SH}}) * \ln(2 * N_{\text{LSB}}) \)
  1. 1. In the above formula, the settling to the desired code value with \( \frac{1}{2} \) LSB or accuracy requires 10 constant time for 12 bits resolution. For 8-bit resolution, the settling time is 7 constant time.
  2. 2. \( C_{\text{SH}} \) is the capacitor in sample and hold mode.
  3. 3. The tolerated voltage drop during the hold phase "Vd" is represented by the number of LSBs after the capacitor discharging with the output leakage current. The settling back to the desired value with \( \frac{1}{2} \) LSB error accuracy requires \( \ln(2 * N_{\text{lsb}}) \) constant time of the DAC.

Example of the sample and refresh time calculation with output buffer on

The values used in the example below are provided as indication only (refer to the datasheet for product data):

\[ C_{\text{SH}} = 100 \text{ nF} \]

\[ V_{\text{REF+}} = 3.0 \text{ V} \]

Sampling phase:

\[ t_{\text{SAMP}} = 7 \mu\text{s} + (10 * 2000 * 100 * 10^{-9}) = 2.007 \text{ ms} \]

(where \( R_{\text{BON}} = 2 \text{ k}\Omega \) )

Refresh phase:

\[ t_{\text{REFRESH}} = 7 \mu\text{s} + (2000 * 100 * 10^{-9}) * \ln(2*10) = 606.1 \mu\text{s} \]

(where \( N_{\text{LSB}} = 10 \) (10 LSB drop during the hold phase))

Hold phase:

\[ D_V = i_{\text{leak}} * t_{\text{hold}} / C_{\text{SH}} = 0.0073 \text{ V} \]

(10 LSB of 12bit at 3 V)

\( i_{\text{leak}} = 150 \text{ nA} \) (worst case on the IO leakage on all the temperature range)

\[ t_{\text{hold}} = 0.0073 * 100 * 10^{-9} / (150 * 10^{-9}) = 4.867 \text{ ms} \]

Figure 242. DAC sample and hold mode phase diagram

Figure 242. DAC sample and hold mode phase diagram. The diagram shows three waveforms over time (t). The top waveform is the DAC output voltage (Vd), which starts at V2, rises to V1 during the Sampling phase, and then decays slightly during the Hold phase. The middle waveform is the dac_hold_ck signal, a high-frequency clock. The bottom waveform is the DAC control signal, which is high (ON) during the Sampling phase and low (OFF) during the Hold and Refresh phases. The phases are labeled: Sampling phase, Hold phase, Refresh phase, and Sampling phase. The diagram is labeled MSV45340V3.
Figure 242. DAC sample and hold mode phase diagram. The diagram shows three waveforms over time (t). The top waveform is the DAC output voltage (Vd), which starts at V2, rises to V1 during the Sampling phase, and then decays slightly during the Hold phase. The middle waveform is the dac_hold_ck signal, a high-frequency clock. The bottom waveform is the DAC control signal, which is high (ON) during the Sampling phase and low (OFF) during the Hold and Refresh phases. The phases are labeled: Sampling phase, Hold phase, Refresh phase, and Sampling phase. The diagram is labeled MSV45340V3.

Like in normal mode, the sample and hold mode has different configurations.

To enable the output buffer, MODEx[2:0] bits in DAC_MCR register must be set to:

To disabled the output buffer, MODEx[2:0] bits in DAC_MCR register must be set to:

When MODEx[2:0] bits are equal to 111, an internal capacitor, \( C_{\text{Lint}} \) , holds the voltage output of the DAC core and then drive it to on-chip peripherals.

All sample and hold phases are interruptible, and any change in DAC_DHRx immediately triggers a new sample phase.

Table 230. Channel output modes summary

MODEx[2:0]ModeBufferOutput connections
000Normal modeEnabledConnected to external pin
001Connected to external pin and to on chip-peripherals (such as comparators)
010DisabledConnected to external pin
011Connected to on chip peripherals (such as comparators)
100Sample and hold modeEnabledConnected to external pin
101Connected to external pin and to on chip peripherals (such as comparators)
110DisabledConnected to external pin and to on chip peripherals (such as comparators)
111Connected to on chip peripherals (such as comparators)

24.4.13 DAC channel buffer calibration

The transfer function for an N-bit digital-to-analog converter (DAC) is:

\[ V_{out} = \left( (D / 2^N) \times G \times V_{REF} \right) + V_{OS} \]

Where \( V_{OUT} \) is the analog output, \( D \) is the digital input, \( G \) is the gain, \( V_{REF} \) is the nominal full-scale voltage, and \( V_{OS} \) is the offset voltage. For an ideal DAC channel, \( G = 1 \) and \( V_{OS} = 0 \) .

Due to output buffer characteristics, the voltage offset may differ from part-to-part and introduce an absolute offset error on the analog output. To compensate the \( V_{OS} \) , a calibration is required by a trimming technique.

The calibration is only valid when the DAC channelx is operating with buffer enabled (MODEx[2:0] = 0b000 or 0b001 or 0b100 or 0b101). if applied in other modes when the buffer is off, it has no effect. During the calibration:

Two calibration techniques are provided:

The DAC buffer offset is factory trimmed. The default value of OTRIMx[4:0] bits in DAC_CCR register is the factory trimming value and it is loaded once DAC digital interface is reset.

The user trimming can be done when the operating conditions differs from nominal factory trimming conditions and in particular when \( V_{DDA} \) voltage, temperature, \( V_{REF+} \) values change and can be done at any point during application by software.

Note: Refer to the datasheet for more details of the nominal factory trimming conditions.

In addition, when \( V_{DD} \) is removed (example the device enters in Standby mode) the calibration is required.

The steps to perform a user trimming calibration are as below:

  1. 1. If the DAC channel is active, write 0 to ENx bit in DAC_CR to disable the channel.
  2. 2. Select a mode where the buffer is enabled, by writing to DAC_MCR register, MODEx[2:0] = 0b000 or 0b001 or 0b100 or 0b101.
  3. 3. Start the DAC channelx calibration, by setting the CENx bit in DAC_CR register to 1.
  4. 4. Apply a trimming algorithm:
    1. a) Write a code into OTRIMx[4:0] bits, starting by 0b00000.
    2. b) Wait for \( t_{TRIM} \) delay.
    3. c) Check if CAL_FLAGx bit in DAC_SR is set to 1.
    4. d) Until the CAL_FLAGx is read as 1 or the maximum trimming code is reached, increment OTRIMx[4:0] and repeat substeps from (b) to (d).

The software algorithm may use either a successive approximation or dichotomy techniques to compute and set the content of OTRIMx[4:0] bits in a faster way.

Note: A \( t_{TRIM} \) delay must be respected between the write to the OTRIMx[4:0] bits and the read of the CAL_FLAGx bit in DAC_SR register in order to get a correct value. This parameter is specified into datasheet electrical characteristics section.

If \( V_{DDA} \) , \( V_{REF+} \) and temperature conditions do not change during device operation while it enters more often in Standby mode, the software may store the OTRIMx[4:0] bits found in the first user calibration in the flash or in back-up registers. then to load/write them directly when the device power is back again thus avoiding to wait for a new calibration time.

When CENx bit is set, it is not allowed to set ENx bit.

24.4.14 DAC channel conversion modes

Four conversion modes are possible.

Independent trigger without wave generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the DAC channel trigger enable bit, TENx.
  2. 2. Configure the trigger sources by setting different values in the TSELx[3:0] bits.
  3. 3. Load the DAC channel data into the desired DHR registers (DAC_DHR12R1, DAC_DHR12L1 or DAC_DHR8R1).

When a DAC channel trigger arrives, the DHRx register is transferred into DAC_DORx (three \( dac\_hclk \) clock cycles later).

Independent trigger with single LFSR generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the DAC channel trigger enable bit, TENx.
  2. 2. Configure the trigger sources by setting different values in the TSELx[3:0] bits.
  3. 3. Configure the DAC channel WAVEx[1:0] bits as 01 and the same LFSR mask value in the MAMPx[3:0] bits.
  4. 4. Load the DAC channel data into the desired DHR register (DAC_DHR12R1, DAC_DHR12L1 or DAC_DHR8R1).

When a DAC channel trigger arrives, the LFSR1 counter, with the same mask, is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). Then the LFSR1 counter is updated.

Independent trigger with single triangle generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the DAC channel trigger enable bits, TENx.
  2. 2. Configure the trigger sources by setting different values in the TSELx[3:0] bits.
  3. 3. Configure the DAC channel WAVEx[1:0] bits as 1x and the same maximum amplitude value in the MAMPx[3:0] bits.
  4. 4. Load the DAC channel data into the desired DHR register (DAC_DHR12R1, DAC_DHR12L1 or DAC_DHR8R1).

When a DAC channel trigger arrives, the DAC channel triangle counter, with the same triangle amplitude, is added to the DHRx register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The DAC channel triangle counter is then updated.

24.4.15 Dual DAC channel conversion modes (if dual channels are available)

To efficiently use the bus bandwidth in applications that require the two DAC channels at the same time, three dual registers are implemented: DHR8RD, DHR12RD and DHR12LD. A unique register access is then required to drive both DAC channels at the same time. For the wave generation, no accesses to DHRxxxD registers are required. As a result, two output channels can be used either independently or simultaneously.

15 conversion modes are possible using the two DAC channels and these dual registers. All the conversion modes can nevertheless be obtained using separate DAC_DHRx registers if needed.

All modes are described in the paragraphs below.

Independent trigger without wave generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  2. 2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bitfields.
  3. 3. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a DAC channel1 trigger arrives, the DHR1 register is transferred into DAC_DOR1 (three dac_hclk clock cycles later).

When a DAC channel2 trigger arrives, the DHR2 register is transferred into DAC_DOR2 (three dac_hclk clock cycles later).

Independent trigger with single LFSR generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  1. 2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bitfields.
  2. 3. Configure the two DAC channel WAVEx[1:0] bits as 01 and the same LFSR mask value in the MAMPx[3:0] bits.
  3. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a DAC channel1 trigger arrives, the LFSR1 counter, with the same mask, is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). Then the LFSR1 counter is updated.

When a DAC channel2 trigger arrives, the LFSR2 counter, with the same mask, is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). Then the LFSR2 counter is updated.

Independent trigger with different LFSR generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  2. 2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bitfields.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 01 and set different LFSR masks values in the MAMP1[3:0] and MAMP2[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a DAC channel1 trigger arrives, the LFSR1 counter, with the mask configured by MAMP1[3:0], is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). Then the LFSR1 counter is updated.

When a DAC channel2 trigger arrives, the LFSR2 counter, with the mask configured by MAMP2[3:0], is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). Then the LFSR2 counter is updated.

Independent trigger with single triangle generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  2. 2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bitfields.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 1x and the same maximum amplitude value in the MAMPx[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a DAC channel1 trigger arrives, the DAC channel1 triangle counter, with the same triangle amplitude, is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The DAC channel1 triangle counter is then updated.

When a DAC channel2 trigger arrives, the DAC channel2 triangle counter, with the same triangle amplitude, is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The DAC channel2 triangle counter is then updated.

Independent trigger with different triangle generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  2. 2. Configure different trigger sources by setting different values in the TSEL1 and TSEL2 bits.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 1x and set different maximum amplitude values in the MAMP1[3:0] and MAMP2[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a DAC channel1 trigger arrives, the DAC channel1 triangle counter, with a triangle amplitude configured by MAMP1[3:0], is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The DAC channel1 triangle counter is then updated.

When a DAC channel2 trigger arrives, the DAC channel2 triangle counter, with a triangle amplitude configured by MAMP2[3:0], is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The DAC channel2 triangle counter is then updated.

Simultaneous software start

To configure the DAC in this conversion mode, the following sequence is required:

In this configuration, one dac_hclk clock cycle later, the DHR1 and DHR2 registers are transferred into DAC_DOR1 and DAC_DOR2, respectively.

Simultaneous trigger without wave generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  2. 2. Configure the same trigger source for both DAC channels by setting the same value in the TSEL1 and TSEL2 bitfields.
  3. 3. Load the dual DAC channel data to the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a trigger arrives, the DHR1 and DHR2 registers are transferred into DAC_DOR1 and DAC_DOR2, respectively (after three dac_hclk clock cycles).

Simultaneous trigger with single LFSR generation

  1. 1. To configure the DAC in this conversion mode, the following sequence is required:
  2. 2. Set the two DAC channel trigger enable bits TEN1 and TEN2.
  3. 3. Configure the same trigger source for both DAC channels by setting the same value in the TSEL1 and TSEL2 bitfields.
  4. 4. Configure the two DAC channel WAVEx[1:0] bits as 01 and the same LFSR mask value in the MAMPx[3:0] bits.
  5. 5. Load the dual DAC channel data to the desired DHR register (DHR12RD, DHR12LD or DHR8RD).

When a trigger arrives, the LFSR1 counter, with the same mask, is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The LFSR1 counter is then updated. At the same time, the LFSR2 counter, with the same mask, is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The LFSR2 counter is then updated.

Simultaneous trigger with different LFSR generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2
  2. 2. Configure the same trigger source for both DAC channels by setting the same value in the TSEL1 and TSEL2 bitfields.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 01 and set different LFSR mask values using the MAMP1[3:0] and MAMP2[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a trigger arrives, the LFSR1 counter, with the mask configured by MAMP1[3:0], is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The LFSR1 counter is then updated.

At the same time, the LFSR2 counter, with the mask configured by MAMP2[3:0], is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The LFSR2 counter is then updated.

Simultaneous trigger with single triangle generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2
  2. 2. Configure the same trigger source for both DAC channels by setting the same value in the TSEL1 and TSEL2 bitfields.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 1x and the same maximum amplitude value using the MAMPx[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a trigger arrives, the DAC channel1 triangle counter, with the same triangle amplitude, is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three dac_hclk clock cycles later). The DAC channel1 triangle counter is then updated.

At the same time, the DAC channel2 triangle counter, with the same triangle amplitude, is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). The DAC channel2 triangle counter is then updated.

Simultaneous trigger with different triangle generation

To configure the DAC in this conversion mode, the following sequence is required:

  1. 1. Set the two DAC channel trigger enable bits TEN1 and TEN2
  2. 2. Configure the same trigger source for both DAC channels by setting the same value in the TSEL1 and TSEL2 bitfields.
  3. 3. Configure the two DAC channel WAVEx[1:0] bits as 1x and set different maximum amplitude values in the MAMP1[3:0] and MAMP2[3:0] bits.
  4. 4. Load the dual DAC channel data into the desired DHR register (DAC_DHR12RD, DAC_DHR12LD or DAC_DHR8RD).

When a trigger arrives, the DAC channel1 triangle counter, with a triangle amplitude configured by MAMP1[3:0], is added to the DHR1 register and the sum is transferred into DAC_DOR1 (three AHB clock cycles later). Then the DAC channel1 triangle counter is updated.

At the same time, the DAC channel2 triangle counter, with a triangle amplitude configured by MAMP2[3:0], is added to the DHR2 register and the sum is transferred into DAC_DOR2 (three dac_hclk clock cycles later). Then the DAC channel2 triangle counter is updated.

24.4.16 DAC autonomous mode

The autonomous mode can be used to update the DAC output voltage in Stop mode. This allows DMA transfers to be performed when the device operates in Run, Sleep or Stop mode. The autonomous mode is supported AUTOMODE only when the DAC is in sample and hold mode. It is enabled by setting the bit in the DAC_AUTOCR register. DMA requests must also be enabled (DMAEN = 1).

When the AUTOMODE bit is set, each hardware trigger signal generates an AHB clock request to the RCC. Once the peripheral receives the AHB clock, the content of the DAC_DHRx register is loaded into DAC_DOR register and a DMA request is generated. When the DMA transaction is complete, the DAC deasserts the AHB clock request and waits for a new trigger event.

When the sample and hold mode is selected, the dac_ker_ck low-power clock must be enabled by the RCC.

DMA transfers in autonomous mode are performed following the sequence described below:

  1. 1. The DAC outputs the voltage on a GPIO or on an on-chip peripheral (dac_ker_ck and dac_hclk are not required).
  2. 2. The DAC receives a hardware trigger from another peripheral.
  3. 3. The DAC asserts the clock request.
  4. 4. The DAC loads the DAC_DHRx register into DAC_DOR register.
  5. 5. The DAC generates a DMA request.
  6. 6. The DMA transfers the new data from memory to DAC_DHRx registers.
  7. 7. The DAC deasserts the clock request.

To initialize the DAC to operate autonomously in Stop mode, follow the sequence below:

  1. 1. Enable the DAC clock autonomous mode in the RCC.
  2. 2. Select the DAC kernel clock in the RCC.
  3. 3. Enable dac_hold_ck clock for the DAC in the RCC.
  4. 4. Select a sample and hold mode through MODEx bit.
  5. 5. Configure the sample and hold mode by setting TSAMPLEx[9:0] , THOLDx[9:0] , TREFRESHx[7:0] bits.
  6. 6. Load the target value into DAC_DHRx register.
  7. 7. Set TENx bit to output the DAC value.
  8. 8. Configure the trigger setting through TSEL[3:0] bits.
  9. 9. Set DMAENx bit and configure the DMA interface.
  10. 10. Set the AUTOMODE bit.

Timing uncertainty of DAC_DHRx to DAC_DOR transfer

After each trigger event, the data contained in DAC_DHRx register is transferred to the DAC_DOR register. Since this transfer is based on AHB clock, the transfer timing depends on the clock availability.

When the AHB clock is stopped, a minimum time is required to restart it. This time depends on the clock source.

24.5 DAC in low-power modes

Table 231. Effect of low-power modes on DAC

ModeDescription
SleepNo effect, DAC used with DMA
Stop 0 (1)The DAC remains functional and can perform DMA transfers in sample and hold mode.
StandbyThe DAC peripheral is powered down and must be reinitialized after exiting Standby or Shutdown mode.
Shutdown
  1. 1. Refer to Section 24.3: DAC implementation for information on the Stop modes supported by the DAC peripheral.

24.6 DAC interrupts

Table 232. DAC interrupts

Interrupt acronymInterrupt eventEvent flagEnable control bitInterrupt clear methodExit Sleep modeExit Stop modeExit Standby mode
DACDMA underrunDMAUDRxDMAUDRIExWrite DMAUDRx = 1YesNoNo

24.7 DAC registers

Refer to Section 1 on page 98 for a list of abbreviations used in register descriptions.

The peripheral registers have to be accessed by words (32-bit).

24.7.1 DAC control register (DAC_CR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.CEN2DMAU
DRIE2
DMAE
N2
MAMP2[3:0]WAVE2[1:0]TSEL2[
3]
TSEL2[
2]
TSEL2[
1]
TSEL2[
0]
TEN2EN2
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
Res.CEN1DMAU
DRIE1
DMAE
N1
MAMP1[3:0]WAVE1[1:0]TSEL1[
3]
TSEL1[
2]
TSEL1[
1]
TSEL1[
0]
TEN1EN1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 Reserved, must be kept at reset value.

Bit 30 CEN2 : DAC channel2 calibration enable

This bit is set and cleared by software to enable/disable DAC channel2 calibration, it can be written only if EN2 bit is set to 0 into DAC_CR (the calibration mode can be entered/exit only when the DAC channel is disabled) Otherwise, the write operation is ignored.

0: DAC channel2 in normal operating mode

1: DAC channel2 in calibration mode

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 29 DMAUDRIE2 : DAC channel2 DMA underrun interrupt enable

This bit is set and cleared by software.

0: DAC channel2 DMA underrun interrupt disabled

1: DAC channel2 DMA underrun interrupt enabled

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 28 DMAEN2 : DAC channel2 DMA enable

This bit is set and cleared by software.

0: DAC channel2 DMA mode disabled

1: DAC channel2 DMA mode enabled

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 27:24 MAMP2[3:0]: DAC channel2 mask/amplitude selector

These bits are written by software to select mask in wave generation mode or amplitude in triangle generation mode.

0000: Unmask bit0 of LFSR/ triangle amplitude equal to 1

0001: Unmask bits[1:0] of LFSR/ triangle amplitude equal to 3

0010: Unmask bits[2:0] of LFSR/ triangle amplitude equal to 7

0011: Unmask bits[3:0] of LFSR/ triangle amplitude equal to 15

0100: Unmask bits[4:0] of LFSR/ triangle amplitude equal to 31

0101: Unmask bits[5:0] of LFSR/ triangle amplitude equal to 63

0110: Unmask bits[6:0] of LFSR/ triangle amplitude equal to 127

0111: Unmask bits[7:0] of LFSR/ triangle amplitude equal to 255

1000: Unmask bits[8:0] of LFSR/ triangle amplitude equal to 511

1001: Unmask bits[9:0] of LFSR/ triangle amplitude equal to 1023

1010: Unmask bits[10:0] of LFSR/ triangle amplitude equal to 2047

≥ 1011: Unmask bits[11:0] of LFSR/ triangle amplitude equal to 4095

Note: These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 23:22 WAVE2[1:0]: DAC channel2 noise/triangle wave generation enable

These bits are set/reset by software.

00: wave generation disabled

01: Noise wave generation enabled

10: Triangle wave generation enabled

11: Reserved

Note: Only used if bit TEN2 = 1 (DAC channel2 trigger enabled)

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 21:18 TSEL2[3:0]: DAC channel2 trigger selection

These bits select the external event used to trigger DAC channel2

0000: SWTRIG2

0001: dac_ch2_trg1

0010: dac_ch2_trg2

...

1111: dac_ch2_trg15

For details on trigger configuration and mapping, refer to Section 24.4.2: DAC pins and internal signals .

Note: Only used if bit TEN2 = 1 (DAC channel2 trigger enabled).

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 17 TEN2: DAC channel2 trigger enable

This bit is set and cleared by software to enable/disable DAC channel2 trigger

0: DAC channel2 trigger disabled and data written into the DAC_DHR2 register are transferred one dac_hclk clock cycle later to the DAC_DOR2 register

1: DAC channel2 trigger enabled and data from the DAC_DHR2 register are transferred three dac_hclk clock cycles later to the DAC_DOR2 register

Note: When software trigger is selected, the transfer from the DAC_DHR2 register to the DAC_DOR2 register takes only one dac_hclk clock cycle.

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 16 EN2 : DAC channel2 enable

This bit is set and cleared by software to enable/disable DAC channel2.

0: DAC channel2 disabled

1: DAC channel2 enabled

Note: These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 15 Reserved, must be kept at reset value.

Bit 14 CEN1 : DAC channel1 calibration enable

This bit is set and cleared by software to enable/disable DAC channel1 calibration, it can be written only if bit EN1 = 0 into DAC_CR (the calibration mode can be entered/exit only when the DAC channel is disabled) Otherwise, the write operation is ignored.

0: DAC channel1 in normal operating mode

1: DAC channel1 in calibration mode

Bit 13 DMAUDRIE1 : DAC channel1 DMA Underrun Interrupt enable

This bit is set and cleared by software.

0: DAC channel1 DMA Underrun Interrupt disabled

1: DAC channel1 DMA Underrun Interrupt enabled

Bit 12 DMAEN1 : DAC channel1 DMA enable

This bit is set and cleared by software.

0: DAC channel1 DMA mode disabled

1: DAC channel1 DMA mode enabled

Bits 11:8 MAMP1[3:0] : DAC channel1 mask/amplitude selector

These bits are written by software to select mask in wave generation mode or amplitude in triangle generation mode.

0000: Unmask bit0 of LFSR/ triangle amplitude equal to 1

0001: Unmask bits[1:0] of LFSR/ triangle amplitude equal to 3

0010: Unmask bits[2:0] of LFSR/ triangle amplitude equal to 7

0011: Unmask bits[3:0] of LFSR/ triangle amplitude equal to 15

0100: Unmask bits[4:0] of LFSR/ triangle amplitude equal to 31

0101: Unmask bits[5:0] of LFSR/ triangle amplitude equal to 63

0110: Unmask bits[6:0] of LFSR/ triangle amplitude equal to 127

0111: Unmask bits[7:0] of LFSR/ triangle amplitude equal to 255

1000: Unmask bits[8:0] of LFSR/ triangle amplitude equal to 511

1001: Unmask bits[9:0] of LFSR/ triangle amplitude equal to 1023

1010: Unmask bits[10:0] of LFSR/ triangle amplitude equal to 2047

≥ 1011: Unmask bits[11:0] of LFSR/ triangle amplitude equal to 4095

Bits 7:6 WAVE1[1:0] : DAC channel1 noise/triangle wave generation enable

These bits are set and cleared by software.

00: wave generation disabled

01: Noise wave generation enabled

10: Triangle wave generation enabled

11: Reserved

Only used if bit TEN1 = 1 (DAC channel1 trigger enabled).

Bits 5:2 TSEL1[3:0] : DAC channel1 trigger selection

These bits select the external event used to trigger DAC channel1

For details on trigger configuration and mapping, refer to Section 24.4.2: DAC pins and internal signals .

Note: Only used if bit TEN1 = 1 (DAC channel1 trigger enabled).

Bit 1 TEN1 : DAC channel1 trigger enable

This bit is set and cleared by software to enable/disable DAC channel1 trigger.

Note: When software trigger is selected, the transfer from the DAC_DHR1 register to the DAC_DOR1 register takes only one dac_hclk clock cycle.

Bit 0 EN1 : DAC channel1 enable

This bit is set and cleared by software to enable/disable DAC channel1.

24.7.2 DAC software trigger register (DAC_SWTRGR)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SWTRIG2SWTRIG1
ww

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 SWTRIG2 : DAC channel2 software trigger

This bit is set by software to trigger the DAC in software trigger mode.

0: No trigger

1: Trigger

Note: This bit is cleared by hardware (one dac_hclk clock cycle later) once the DAC_DHR2 register value has been loaded into the DAC_DOR2 register.

This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 0 SWTRIG1 : DAC channel1 software trigger

This bit is set by software to trigger the DAC in software trigger mode.

0: No trigger

1: Trigger

Note: This bit is cleared by hardware (one dac_hclk clock cycle later) once the DAC_DHR1 register value has been loaded into the DAC_DOR1 register.

24.7.3 DAC channel1 12-bit right-aligned data holding register (DAC_DHR12R1)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.DACC1DHRB[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.DACC1DHR[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:28 Reserved, must be kept at reset value.

Bits 27:16 DACC1DHRB[11:0] : DAC channel1 12-bit right-aligned data B

These bits are written by software. They specify 12-bit data for DAC channel1 when the DAC operates in double data mode.

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DACC1DHR[11:0] : DAC channel1 12-bit right-aligned data

These bits are written by software. They specify 12-bit data for DAC channel1.

24.7.4 DAC channel1 12-bit left aligned data holding register (DAC_DHR12L1)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
DACC1DHRB[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DACC1DHR[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 DACC1DHRB[11:0] : DAC channel1 12-bit left-aligned data B

These bits are written by software. They specify 12-bit data for DAC channel1 when the DAC operates in double data mode.

Bits 19:16 Reserved, must be kept at reset value.

Bits 15:4 DACC1DHR[11:0] : DAC channel1 12-bit left-aligned data

These bits are written by software.
They specify 12-bit data for DAC channel1.

Bits 3:0 Reserved, must be kept at reset value.

24.7.5 DAC channel1 8-bit right aligned data holding register (DAC_DHR8R1)

Address offset: 0x10

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
DACC1DHRB[7:0]DACC1DHR[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:8 DACC1DHRB[7:0] : DAC channel1 8-bit right-aligned data

These bits are written by software. They specify 8-bit data for DAC channel1 when the DAC operates in double data mode.

Bits 7:0 DACC1DHR[7:0] : DAC channel1 8-bit right-aligned data

These bits are written by software. They specify 8-bit data for DAC channel1.

24.7.6 DAC channel2 12-bit right aligned data holding register (DAC_DHR12R2)

This register is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Address offset: 0x14

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.DACC2DHRB[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.DACC2DHR[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:28 Reserved, must be kept at reset value.

Bits 27:16 DACC2DHRB[11:0] : DAC channel2 12-bit right-aligned data

These bits are written by software. They specify 12-bit data for DAC channel2 when the DAC operates in DMA double data mode.

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DACC2DHR[11:0] : DAC channel2 12-bit right-aligned data

These bits are written by software. They specify 12-bit data for DAC channel2.

24.7.7 DAC channel2 12-bit left aligned data holding register (DAC_DHR12L2)

This register is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Address offset: 0x18

Reset value: 0x0000 0000

31302928272625242322212019181716
DACC2DHRB[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DACC2DHR[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 DACC2DHRB[11:0] : DAC channel2 12-bit left-aligned data B

These bits are written by software. They specify 12-bit data for DAC channel2 when the DAC operates in double data mode.

Bits 19:16 Reserved, must be kept at reset value.

Bits 15:4 DACC2DHR[11:0] : DAC channel2 12-bit left-aligned data

These bits are written by software which specify 12-bit data for DAC channel2.

Bits 3:0 Reserved, must be kept at reset value.

24.7.8 DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2)

This register is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Address offset: 0x1C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
DACC2DHRB[7:0]DACC2DHR[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:8 DACC2DHRB[7:0] : DAC channel2 8-bit right-aligned data

These bits are written by software. They specify 8-bit data for DAC channel2 when the DAC operates in double data mode.

Bits 7:0 DACC2DHR[7:0] : DAC channel2 8-bit right-aligned data

These bits are written by software which specifies 8-bit data for DAC channel2.

24.7.9 Dual DAC 12-bit right-aligned data holding register (DAC_DHR12RD)

Address offset: 0x20

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.DACC2DHR[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res. Res. Res. Res.DACC1DHR[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:28 Reserved, must be kept at reset value.

Bits 27:16 DACC2DHR[11:0] : DAC channel2 12-bit right-aligned data

These bits are written by software which specifies 12-bit data for DAC channel2.

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DACC1DHR[11:0] : DAC channel1 12-bit right-aligned data

These bits are written by software which specifies 12-bit data for DAC channel1.

24.7.10 Dual DAC 12-bit left aligned data holding register (DAC_DHR12LD)

Address offset: 0x24

Reset value: 0x0000 0000

31302928272625242322212019181716
DACC2DHR[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DACC1DHR[11:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 DACC2DHR[11:0] : DAC channel2 12-bit left-aligned data

These bits are written by software which specifies 12-bit data for DAC channel2.

Bits 19:16 Reserved, must be kept at reset value.

Bits 15:4 DACC1DHR[11:0] : DAC channel1 12-bit left-aligned data

These bits are written by software which specifies 12-bit data for DAC channel1.

Bits 3:0 Reserved, must be kept at reset value.

24.7.11 Dual DAC 8-bit right aligned data holding register (DAC_DHR8RD)

Address offset: 0x28

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
DACC2DHR[7:0]DACC1DHR[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:8 DACC2DHR[7:0] : DAC channel2 8-bit right-aligned data

These bits are written by software which specifies 8-bit data for DAC channel2.

Bits 7:0 DACC1DHR[7:0] : DAC channel1 8-bit right-aligned data

These bits are written by software which specifies 8-bit data for DAC channel1.

24.7.12 DAC channel1 data output register (DAC_DOR1)

Address offset: 0x2C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.DACC1DORB[11:0]
rrrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.DACC1DOR[11:0]
rrrrrrrrrrrr

Bits 31:28 Reserved, must be kept at reset value.

Bits 27:16 DACC1DORB[11:0] : DAC channel1 data output

These bits are read-only. They contain data output for DAC channel1 B.

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DACC1DOR[11:0] : DAC channel1 data output

These bits are read-only, they contain data output for DAC channel1.

24.7.13 DAC channel2 data output register (DAC_DOR2)

This register is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Address offset: 0x30

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.DACC2DORB[11:0]
rrrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.DACC2DOR[11:0]
rrrrrrrrrrrr

Bits 31:28 Reserved, must be kept at reset value.

Bits 27:16 DACC2DORB[11:0] : DAC channel2 data output

These bits are read-only. They contain data output for DAC channel2 B.

Bits 15:12 Reserved, must be kept at reset value.

Bits 11:0 DACC2DOR[11:0] : DAC channel2 data output

These bits are read-only, they contain data output for DAC channel2.

24.7.14 DAC status register (DAC_SR)

Address offset: 0x34

Reset value: 0x0000 0000

31302928272625242322212019181716
BWST2CAL_F
LAG2
DMAU
DR2
DORST
AT2
DAC2R
DY
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rrrc_w1rr

1514131211109876543210
BWST1CAL_F
LAG1
DMAU
DR1
DORST
AT1
DAC1R
DY
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rrrc_w1rr

Bit 31 BWST2 : DAC channel2 busy writing sample time flag

This bit is systematically set just after sample and hold mode enable. It is set each time the software writes the register DAC_SHSR2. It is cleared by hardware when the write operation of DAC_SHSR2 is complete. (It takes about 3 LSI/LSE periods of synchronization).

0: There is no write operation of DAC_SHSR2 ongoing: DAC_SHSR2 can be written

1: There is a write operation of DAC_SHSR2 ongoing: DAC_SHSR2 cannot be written

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 30 CAL_FLAG2 : DAC channel2 calibration offset status

This bit is set and cleared by hardware

0: calibration trimming value is lower than the offset correction value

1: calibration trimming value is equal or greater than the offset correction value

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 29 DMAUDR2 : DAC channel2 DMA underrun flag

This bit is set by hardware and cleared by software (by writing it to 1).

0: No DMA underrun error condition occurred for DAC channel2

1: DMA underrun error condition occurred for DAC channel2 (the currently selected trigger is driving DAC channel2 conversion at a frequency higher than the DMA service capability rate).

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 28 DORSTAT2 : DAC channel2 output register status bit

This bit is set and cleared by hardware. It is applicable only when the DAC operates in double data mode.

0: DOR[11:0] is used actual DAC output

1: DORB[11:0] is used actual DAC output

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 27 DAC2RDY : DAC channel2 ready status bit

This bit is set and cleared by hardware.

0: DAC channel2 is not yet ready to accept the trigger nor output data

1: DAC channel2 is ready to accept the trigger or output data

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 26:16 Reserved, must be kept at reset value.

Bit 15 BWST1 : DAC channel1 busy writing sample time flag

This bit is systematically set just after sample and hold mode enable and is set each time the software writes the register DAC_SHSR1. It is cleared by hardware when the write operation of DAC_SHSR1 is complete. (It takes about 3 LSI/LSE periods of synchronization).

0: There is no write operation of DAC_SHSR1 ongoing: DAC_SHSR1 can be written

1: There is a write operation of DAC_SHSR1 ongoing: DAC_SHSR1 cannot be written

Bit 14 CAL_FLAG1 : DAC channel1 calibration offset status

This bit is set and cleared by hardware

0: calibration trimming value is lower than the offset correction value

1: calibration trimming value is equal or greater than the offset correction value

Bit 13 DMAUDR1 : DAC channel1 DMA underrun flag

This bit is set by hardware and cleared by software (by writing it to 1).

0: No DMA underrun error condition occurred for DAC channel1

1: DMA underrun error condition occurred for DAC channel1 (the currently selected trigger is driving DAC channel1 conversion at a frequency higher than the DMA service capability rate)

Bit 12 DORSTAT1 : DAC channel1 output register status bit

This bit is set and cleared by hardware. It is applicable only when the DAC operates in double data mode.

0: DOR[11:0] is used actual DAC output

1: DORB[11:0] is used actual DAC output

Bit 11 DAC1RDY : DAC channel1 ready status bit

This bit is set and cleared by hardware.

0: DAC channel1 is not yet ready to accept the trigger nor output data

1: DAC channel1 is ready to accept the trigger or output data

Bits 10:0 Reserved, must be kept at reset value.

24.7.15 DAC calibration control register (DAC_CCR)

Address offset: 0x38

Reset value: 0x00XX 00XX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OTRIM2[4:0]
rwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OTRIM1[4:0]
rwrwrwrwrw

Bits 31:21 Reserved, must be kept at reset value.

Bits 20:16 OTRIM2[4:0] : DAC channel2 offset trimming value

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 15:5 Reserved, must be kept at reset value.

Bits 4:0 OTRIM1[4:0] : DAC channel1 offset trimming value

24.7.16 DAC mode control register (DAC_MCR)

Address offset: 0x3C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.SINFORMAT2DMADDOUBLE2Res.Res.Res.Res.Res.MODE2[2:0]
rwrwrwrwrw

1514131211109876543210
HFSEL[1:0]Res.Res.Res.Res.SINFORMAT1DMADDOUBLE1Res.Res.Res.Res.Res.MODE1[2:0]
rwrwrwrwrwrwrw

Bits 31:26 Reserved, must be kept at reset value.

Bit 25 SINFORMAT2 : Enable signed format for DAC channel2

This bit is set and cleared by software.

0: Input data is in unsigned format

1: Input data is in signed format (2's complement). The MSB bit represents the sign.

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bit 24 DMADDOUBLE2 : DAC channel2 DMA double data mode

This bit is set and cleared by software.

0: DMA normal mode selected

1: DMA double data mode selected

Note: This bit is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Bits 23:19 Reserved, must be kept at reset value.

Bits 18:16 MODE2[2:0] : DAC channel2 mode

These bits can be written only when the DAC is disabled and not in the calibration mode (when bit EN2 = 0 and bit CEN2 = 0 in the DAC_CR register). If EN2 = 1 or CEN2 = 1 the write operation is ignored.

They can be set and cleared by software to select the DAC channel2 mode:

– DAC channel2 in normal mode

000: DAC channel2 is connected to external pin with Buffer enabled

001: DAC channel2 is connected to external pin and to on chip peripherals with buffer enabled

010: DAC channel2 is connected to external pin with buffer disabled

011: DAC channel2 is connected to on chip peripherals with Buffer disabled

– DAC channel2 in sample and hold mode

100: DAC channel2 is connected to external pin with Buffer enabled

101: DAC channel2 is connected to external pin and to on chip peripherals with Buffer enabled

110: DAC channel2 is connected to external pin and to on chip peripherals with Buffer disabled

111: DAC channel2 is connected to on chip peripherals with Buffer disabled

Note: This register can be modified only when EN2 = 0.

Refer to Section 24.3: DAC implementation for the availability of DAC channel2.

Bits 15:14 HFSEL[1:0] : High frequency interface mode selection

Bits 13:10 Reserved, must be kept at reset value.

Bit 9 SINFORMAT1 : Enable signed format for DAC channel1
This bit is set and cleared by software.

Bit 8 DMADDOUBLE1 : DAC channel1 DMA double data mode
This bit is set and cleared by software.

Bits 7:3 Reserved, must be kept at reset value.

Bits 2:0 MODE1[2:0] : DAC channel1 mode
These bits can be written only when the DAC is disabled and not in the calibration mode (when bit EN1 = 0 and bit CEN1 = 0 in the DAC_CR register). If EN1 = 1 or CEN1 = 1 the write operation is ignored.
They can be set and cleared by software to select the DAC channel1 mode:

Note: This register can be modified only when EN1 = 0.

24.7.17 DAC channel1 sample and hold sample time register (DAC_SHSR1)

Address offset: 0x40

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.TSAMPLE1[9:0]
rwrwrwrwrwrwrwrwrwrw

Bits 31:10 Reserved, must be kept at reset value.

Bits 9:0 TSAMPLE1[9:0] : DAC channel1 sample time (only valid in sample and hold mode)

These bits can be written when the DAC channel1 is disabled or also during normal operation. In the latter case, the write can be done only when BWST1 of DAC_SR register is low. If BWST1 = 1, the write operation is ignored.

Note: It represents the number of LSI/LSE clocks to perform a sample phase. Sampling time = (TSAMPLE1[9:0] + 1) x LSI/LSE clock period.

24.7.18 DAC channel2 sample and hold sample time register (DAC_SHSR2)

This register is available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Address offset: 0x44

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.TSAMPLE2[9:0]
rwrwrwrwrwrwrwrwrwrw

Bits 31:10 Reserved, must be kept at reset value.

Bits 9:0 TSAMPLE2[9:0] : DAC channel2 sample time (only valid in sample and hold mode)

These bits can be written when the DAC channel2 is disabled or also during normal operation. In the latter case, the write can be done only when BWST2 of DAC_SR register is low. If BWST2 = 1, the write operation is ignored.

Note: It represents the number of LSI/LSE clocks to perform a sample phase. Sampling time = (TSAMPLE1[9:0] + 1) x LSI/LSE clock period.

24.7.19 DAC sample and hold time register (DAC_SHHR)

Address offset: 0x48

Reset value: 0x0001 0001

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.THOLD2[9:0]
rwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.THOLD1[9:0]
rwrwrwrwrwrwrwrwrwrw

Bits 31:26 Reserved, must be kept at reset value.

Bits 25:16 THOLD2[9:0] : DAC channel2 hold time (only valid in sample and hold mode).

Hold time = (THOLD[9:0]) x LSI/LSE clock period

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Note: This register can be modified only when EN2 = 0.

Bits 15:10 Reserved, must be kept at reset value.

Bits 9:0 THOLD1[9:0] : DAC channel1 hold time (only valid in sample and hold mode)

Hold time = (THOLD[9:0]) x LSI/LSE clock period

Note: This register can be modified only when EN1 = 0.

Note: These bits can be written only when the DAC channel is disabled and in normal operating mode (when bit ENx = 0 and bit CENx = 0 in the DAC_CR register). If ENx = 1 or CENx = 1 the write operation is ignored.

24.7.20 DAC sample and hold refresh time register (DAC_SHRR)

Address offset: 0x4C

Reset value: 0x0001 0001

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.TREFRESH2[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.TREFRESH1[7:0]
rwrwrwrwrwrwrwrw

Bits 31:24 Reserved, must be kept at reset value.

Bits 23:16 TREFRESH2[7:0] : DAC channel2 refresh time (only valid in sample and hold mode)

Refresh time = (TREFRESH[7:0]) x LSI/LSE clock period

These bits are available only on dual-channel DACs. Refer to Section 24.3: DAC implementation .

Note: This register can be modified only when EN2 = 0.

Bits 15:8 Reserved, must be kept at reset value.

Bits 7:0 TREFRESH1[7:0] : DAC channel1 refresh time (only valid in sample and hold mode)

Refresh time = (TREFRESH[7:0]) x LSI/LSE clock period

Note: This register can be modified only when EN1 = 0.

Note: These bits can be written only when the DAC channel is disabled and in normal operating mode (when bit ENx = 0 and bit CENx = 0 in the DAC_CR register). If ENx = 1 or CENx = 1 the write operation is ignored.

24.7.21 DAC autonomous mode control register (DAC_AUTOCR)

Address offset: 0x54

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.AUTO
MODE
Res.Res.Res.Res.Res.Res.
rw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 AUTOMODE : DAC autonomous mode

This bit is set and cleared by software.
0: DAC autonomous mode disabled
1: DAC autonomous mode enabled

Bits 21:0 Reserved, must be kept at reset value.

24.7.22 DAC register map

Table 233 summarizes the DAC registers.

Table 233. DAC register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x00DAC_CRRes.CEN2DMAUDRIE2DMAEN2MAMP2[3:0]WAVE2[2:0]TSEL2[3:1]TSEL2[0]TEN2EN2Res.CEN1DMAUDRIE1DMAEN1MAMP1[3:0]WAVE1[1:0]TSEL1[3:1]TSEL1[0]TEN1EN1
0000000000000000000000000000000
0x04DAC_SWTRGRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SWTRIG2SWTRIG1
00
0x08DAC_DHR12R1Res.Res.Res.Res.DACC1DHRB[11:0]Res.Res.Res.Res.DACC1DHR[11:0]
000000000000000000000000
0x0CDAC_DHR12L1DACC1DHRB[11:0]Res.Res.Res.Res.DACC1DHR[11:0]Res.Res.Res.Res.
000000000000000000000000
0x10DAC_DHR8R1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DACC1DHRB[7:0]DACC1DHR[7:0]
0000000000000000
0x14DAC_DHR12R2Res.Res.Res.Res.DACC2DHRB[11:0]Res.Res.Res.Res.DACC2DHR[11:0]
000000000000000000000000

Table 233. DAC register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x18DAC_DHR12L2DACC2DHRB[11:0]ResResResResDACC2DHR[11:0]ResResResResRes
Reset value0000000000000000000000000000
0x1CDAC_DHR8R2ResResResResResResResResResResResResResResResResDACC2DHRB[7:0]DACC2DHR[7:0]
Reset value000000000000000
0x20DAC_DHR12RDResResResResDACC2DHR[11:0]ResResResResDACC1DHR[11:0]
Reset value00000000000000000000000
0x24DAC_DHR12LDDACC2DHR[11:0]ResResResResDACC1DHR[11:0]ResResResResRes
Reset value000000000000000000000000000
0x28DAC_DHR8RDResResResResResResResResResResResResResResResResDACC2DHR[7:0]DACC1DHR[7:0]
Reset value000000000000000
0x2CDAC_DOR1ResResResResDACC1DORB[11:0]ResResResResDACC1DOR[11:0]
Reset value00000000000000000000000
0x30DAC_DOR2ResResResResDACC2DORB[11:0]ResResResResDACC2DOR[11:0]
Reset value00000000000000000000000
0x34DAC_SRBWST2CAL_FLAG2DMAUDR2DORSTAT2DAC2RDYResResResResResResResResResResResBWST1CAL_FLAG1DMAUDR1DORSTAT1DAC1RDYResResResResResResResResResResRes
Reset value0000000000
0x38DAC_CCRResResResResResResResResResResResResOTRIM2[4]OTRIM2[3]OTRIM2[2]OTRIM2[1]OTRIM2[0]ResResResResResResResResResResResOTRIM1[4]OTRIM1[3]OTRIM1[2]OTRIM1[1]OTRIM1[0]
Reset valueXXXXXXXXXX
0x3CDAC_MCRResResResResResResSINFORMAT2DWADDOUBLE2ResResResResResMODE2[2:0]ResResHFSEL[1]HFSEL[0]ResResResResResResResResResResResResMODE1[2:0]Res
Reset value000000
0x40DAC_SHSR1ResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResRes
Reset value
0x44DAC_SHSR2ResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResRes
Reset value
0x48DAC_SHHRResResResResResResTHOLD2[9:0]ResResResResResResTHOLD1[9:0]
Reset value00000000010000000001
0x4CDAC_SHRRResResResResResResResResTREFRESH2[7:0]ResResResResResResResResResResResResResResResRes
Reset value00000001
0x50Reserved

Table 233. DAC register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x54DAC_AUTOCRRes.Res.Res.Res.Res.Res.Res.Res.Res.AUTOMODERes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0
0x58-
0x60
Reserved
0x64-
0x68
Reserved

Refer to Section 2.3: Memory organization for the register boundary addresses.