STM32 DAC for resolver excitation
Posted: Thu May 06, 2021 3:40 pm
I found a sudden urge to experiment with the DAC. I have here an STM32F107VCT6.
Just sort of "blogging" about it here.
Starting out simple with software triggering. First had to upgrade libopencm3 because the forked version didn't have DAC functions.
setup:
In cyclic 10 ms task:
seq1Ctr is a 0-3 counter.
result:
Just sort of "blogging" about it here.
Starting out simple with software triggering. First had to upgrade libopencm3 because the forked version didn't have DAC functions.
setup:
Code: Select all
rcc_periph_clock_enable(RCC_DAC); //CAN
dac_enable(DAC1, DAC_CHANNEL1);
dac_set_trigger_source(DAC1, DAC_CR_TSEL1_SW);
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO5);
Code: Select all
seq1Ctr = (seq1Ctr + 1) & 0x3;
dac_load_data_buffer_single(DAC1, seq1Ctr << 10, DAC_ALIGN_RIGHT12, DAC_CHANNEL1);
dac_software_trigger(DAC1, DAC_CHANNEL1);
result: