Skip to content

DAC1 channel 2 and DAC2 channel 1 are not working on STM32F303 #1324

Closed
@kiiv-cz

Description

@kiiv-cz

Only the first channel on DAC1 is working on STM32F303 (k8) as it's the only one with output buffer:

dacChannelConf.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;

The other two channels are using output switch instead of output buffer enable: dacChannelConf.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE;

As the HAL is using only correct struct member, it should be possible to set both without any interference:
dacChannelConf.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
dacChannelConf.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE;
This solves issue that DAC1 channel 2 and DAC2 channel 1 are not getting routed out to the output pins.

However there is another issue with initialization (after the previous fix):
analogWriteResolution(12);
analogWrite(A4,512); // output is active for 5 seconds
delay(5000);
analogWrite(A3,1512); // now HAL_DAC_MspDeinit is called prior to initialize second channel and A4 is now floating
analogWrite(A5,2512); // this channel is working after the fix

Changing the order of first usage A3/A4 changes which one stops working (first one used stops working after the other channel gets "initialized" too)

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions