arduino / arduino/ArduinoCore-sam
adc_disable_channel_differential_input does not correctly set config bit
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/arduino/ArduinoCore-sam/blob/c893c62ec9953ed36a256b5243272fda2e473c14/system/libsam/source/adc.c#L632-L635
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in system/libsam/source/adc.c at lines 632-635 and inspect adc_disable_channel_differential_input alongside adc_enable_channel_differential_input. Verify the register mask behavior using the issue's truth table, then confirm that disabling a channel after enabling differential input clears the differential-input configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100