LL DAC Macros

Common write and read registers macros

group DAC_LL_EM_WRITE_READ

Defines

LL_DAC_WRITE_REG ( instance , reg , value ) STM32_WRITE_REG((instance)->reg, (value))

Write a value in DAC register.

Parameters :
  • instance – DAC Instance

  • reg – Register to be written

  • value – Value to be written in the register

LL_DAC_READ_REG ( instance , reg ) STM32_READ_REG((instance)->reg)

Read a value in DAC register.

Parameters :
  • instance – DAC Instance

  • reg – Register to be read

Return values :

Register – value

DAC helper macro

group DAC_LL_EM_HELPER_MACRO

Defines

LL_DAC_CHANNEL_TO_DECIMAL_NB ( channel ) ((channel) & DAC_SWTR_CHX_MASK )

Helper macro to get DAC channel number in decimal format from literals LL_DAC_CHANNEL_x. Example: LL_DAC_CHANNEL_TO_DECIMAL_NB(LL_DAC_CHANNEL_1) returns decimal number “1”.

Note

The input can be a value from functions where a channel number is returned.

Parameters :
Return values :

1...2

LL_DAC_DECIMAL_NB_TO_CHANNEL ( decimal_nb ) (((decimal_nb) == 1UL) ? ( LL_DAC_CHANNEL_1 ) : (((decimal_nb) == 2UL) ? ( LL_DAC_CHANNEL_2 ):(0UL)))

Helper macro to get DAC channel in literal format LL_DAC_CHANNEL_x from number in decimal format. Example: LL_DAC_DECIMAL_NB_TO_CHANNEL(1) returns a data equivalent to “LL_DAC_CHANNEL_1”.

Note

If the input parameter does not correspond to a DAC channel, this macro returns value ‘0’.

Parameters :
  • decimal_nb – 1…2

Return values :

Returned – value can be one of the following values:

LL_DAC_DIGITAL_SCALE ( dac_resolution ) ((0x00000FFFUL) >> ((dac_resolution) << 1UL))

Helper macro to define the DAC conversion data full-scale digital value corresponding to the selected DAC resolution.

Note

DAC conversion data full-scale corresponds to voltage range determined by analog voltage references Vref+ and Vref- (refer to reference manual).

Parameters :
Return values :

ADC – conversion data equivalent voltage value (unit: mVolt)

LL_DAC_CALC_VOLTAGE_TO_DATA ( vrefanalog_voltage , dac_voltage , dac_resolution ) ((dac_voltage) * LL_DAC_DIGITAL_SCALE (dac_resolution) / (vrefanalog_voltage))

Helper macro to calculate the DAC conversion data (unit: digital value) corresponding to a voltage (unit: mVolt).

Note

This helper macro is intended to provide input data in voltage rather than digital value, to be used with LL DAC functions such as LL_DAC_ConvertData12RightAligned() .

Note

Analog reference voltage (Vref+) must be either known from user board environment or can be calculated using ADC measurement and ADC helper macro LL_ADC_CALC_VREFANALOG_VOLTAGE() .

Parameters :
  • vrefanalog_voltage – Analog reference voltage (unit: mV)

  • dac_voltage – Voltage to be generated by DAC channel (unit: mVolt).

  • dac_resolution – This parameter can be one of the following values:

Return values :

DAC – conversion data (unit: digital value)