2025-02-04 03:25 PM - last edited on 2025-02-04 10:47 PM by SofLit
Driving DAC1 channel 1 with
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
...
while (1) {
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 4095UL);
HAL_Delay(100UL);
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 0UL);
HAL_Delay(100UL);
}
to generate 5 Hz, 50% duty cycle, 0 - 2.5v. Amplitude as expected but frequency varies from 1 - 4s and duty cycle varies from 20 - 80%: not expected. DAC1 configured like
DAC1 clocked at 65 MHz. When I step into HAL_DAC_SetValue() I see where the 0 - 4095 value is written to data register (12-bit, right-aligned). But sometimes after writing 4095 the output pin reads zero; and sometimes after writing zero the output pin reads 2.5v. I can't explain why this happens. DAC Instance following write looks like
I am the only writer on the data register.