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

adc_disable_channel_differential_input does not correctly set config bit #102

Open
natgaertner opened this issue Mar 10, 2020 · 0 comments

Comments

@natgaertner
Copy link

uint32_t ul_temp;
ul_temp = p_adc->ADC_COR;
p_adc->ADC_COR &= 0xfffeffffu << channel;
p_adc->ADC_COR |= ul_temp;

By ORing with the previous value, the resulting of ANDing with the mask is undone, so the function results in no action being taken (once adc_enable_channel_differential_input is run, adc_disable_channel_differential_input doesn't work).
trivially with one bit, the truth table for (A and B) or A is:

A B (A and B) or A
T T T
T F T
F T F
F F F

I believe the desired result could be obtained by ORing with the set value (basically running adc_enable_channel_differential_input), then XORing with the same value, but I'm not a good enough C programmer to know if this is the optimal way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant