-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/sam0_common: enable static voltages #21555
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
Conversation
DAC_CTRLA_SWRST clears all registers, so it also clears the config of the first DAC line after configuring the second DAC line.
/* Settings can only be changed when DAC is disabled, reset config */ | ||
DAC->CTRLA.reg = DAC_CTRLA_SWRST; | ||
/* Settings can only be changed when DAC is disabled */ | ||
DAC->CTRLA.reg &= ~DAC_CTRLA_ENABLE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are only two bits, you could also just
DAC->CTRLA.reg &= ~DAC_CTRLA_ENABLE; | |
DAC->CTRLA.reg = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some CPUs there are three bits. One of them is the bit to enable operation during standby power mode:
typedef union {
struct {
uint8_t SWRST:1; /*!< bit: 0 Software Reset */
uint8_t ENABLE:1; /*!< bit: 1 Enable */
uint8_t RUNSTDBY:1; /*!< bit: 2 Run in Standby */
uint8_t :5; /*!< bit: 3.. 7 Reserved */
} bit; /*!< Structure used for bit access */
uint8_t reg; /*!< Type used for register access */
} DAC_CTRLA_Type;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now you are writing the entire CTRLA
reg anyway at the end, you might as well set it all to 0 here 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But 0 feels like a magic number to me and I like the fact that clearing the bit makes the intention clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it saves two instructions - but yea, not really that much relevant on init.
Head branch was pushed to by a user without write access
fc2f722
to
e2695eb
Compare
e2695eb
to
4e442a8
Compare
4e442a8
to
4259152
Compare
check commits thinks your commit message is too long 😕 (>72 characters) |
4259152
to
b157d5c
Compare
Contribution description
The DAC needs to set up a conversion refresh in order to hold a static voltage, so just do it by default. Also add the option to keep the DAC running during standby mode.
Testing procedure
Can be tested with
tests/periph/dac/main.c
e.g. on asame54-xpro
.Issues/PRs references
Fixes a configuration issue introduced by #21548