Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32/periph/dac: optimize setting DAC #19529

Merged
merged 1 commit into from
May 2, 2023

Conversation

Enoch247
Copy link
Contributor

@Enoch247 Enoch247 commented May 1, 2023

Contribution description

The current implmentation right shifted the 16 bit value passed into dac_set() down to the 12 bits that the DAC is actually capable of. This patch drops the shift and instead writes the 16 bit value to the DAC's left aligned 12 bit wide data holding register.

Testing procedure

do something like:

#include "perip/dac.h"

int main(void)
{
    dac_set(DAC_LINE(0), 0xffff/2);
    return 0;
}
  • observe DAC's output is half of vref

Issues/PRs references

  • none known

The current implmentation right shifted the 16 bit value passed into
`dac_set()` down to the 12 bits that the DAC is actually capable of.
This patch drops the shift and instead writes the 16 bit value to the
DAC's left aligned 12 bit wide data holding register.
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels May 1, 2023
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 2, 2023
@riot-ci
Copy link

riot-ci commented May 2, 2023

Murdock results

✔️ PASSED

1134424 cpu/stm32/periph/dac: optimize setting DAC

Success Failures Total Runtime
6931 0 6931 09m:52s

Artifacts

@benpicco
Copy link
Contributor

benpicco commented May 2, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented May 2, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 718a451 into RIOT-OS:master May 2, 2023
@Enoch247 Enoch247 deleted the stm32-dac-left-align branch May 3, 2023 15:24
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants