DAC
Code generation emits one STM32DAC object for each DAC output channel enabled in CubeMX, with the initial output voltage and the reference voltage taken from libxr_config.yaml.
Example
The generator reads each enabled DAC channel and emits code like:
static STM32DAC dac1_out2(&hdac1, DAC_CHANNEL_2, 0.0, 3.3);
Configuration File
After the previous generation step, a DAC section appears in User/libxr_config.yaml:
DAC:
dac1:
init_voltage: 0.0
vref: 3.3
init_voltage: initial output voltagevref: reference voltage
Generation Rules
- each enabled output channel gets one object named
<instance>_<channel>, such asdac1_out2; DAC_OUTxis written asDAC_CHANNEL_x;- the constructor arguments come from
DAC.<instance>.init_voltage(default 0.0) andDAC.<instance>.vref(default 3.3); - a DAC peripheral without enabled channels gets no object.
After editing the file, regenerate the code with the commands in Regenerating the Code.