Skip to content

tests/adc: always test all resolutions#21223

Merged
mguetschow merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/adc_test
Feb 20, 2025
Merged

tests/adc: always test all resolutions#21223
mguetschow merged 1 commit intoRIOT-OS:masterfrom
crasbe:pr/adc_test

Conversation

@crasbe
Copy link
Copy Markdown
Contributor

@crasbe crasbe commented Feb 18, 2025

Contribution description

During my work on the STM32 ADC, I struggled with the original tests/periph/adc test, since it only samples at 10 bit and has to be recompiled for different resolutions.
The changes were already discussed in #20780.

Testing procedure

Get your favorite devboard with an ADC (some STM32s like F0,G0,C0 might show weird values due to #21222) and run the test with BOARD=nucleo-l073rz make -C tests/periph/adc flash term.

You should see the new output from the test with all resolutions. Keep a jumper wire at hand to set the analog inputs to ground and VCC to see that they are at the appropriate values.

This is the new output with this PR:

main(): This is RIOT! (Version: 2024.04-devel-2100-g1cb67-pr/adc_test)<\n>
<\n>
RIOT ADC peripheral driver test<\n>
<\n>
This test will sample all available ADC lines once every 100ms with<\n>
6 to 16-bit resolution and print the sampled results to STDOUT.<\n>
Not all MCUs support all resolutions, unsupported resolutions<\n>
are printed as -1.<\n>
<\n>
Successfully initialized ADC_LINE(0)<\n>
Successfully initialized ADC_LINE(1)<\n>
Successfully initialized ADC_LINE(2)<\n>
Successfully initialized ADC_LINE(3)<\n>
Successfully initialized ADC_LINE(4)<\n>
Successfully initialized ADC_LINE(5)<\n>
ADC_LINE(0):  1   1    3    8    -1    -1<\n>
ADC_LINE(1): 63 255 1023 4095    -1    -1<\n>
ADC_LINE(2): 10  21   44   90    -1    -1<\n>
ADC_LINE(3):  7  32  131  529    -1    -1<\n>
ADC_LINE(4):  7  32  134  541    -1    -1<\n>
ADC_LINE(5):  8  33  129  520    -1    -1<\n>
<\n>
ADC_LINE(0):  0   1    2    8    -1    -1<\n>
ADC_LINE(1): 63 255 1023 4095    -1    -1<\n>
ADC_LINE(2):  9  20   42   87    -1    -1<\n>
ADC_LINE(3):  7  32  130  528    -1    -1<\n>
ADC_LINE(4):  7  32  134  535    -1    -1<\n>
ADC_LINE(5):  7  33  131  515    -1    -1<\n>
<\n>
ADC_LINE(0):  0   1    2    9    -1    -1<\n>
ADC_LINE(1): 63 255 1023 4095    -1    -1<\n>
ADC_LINE(2):  9  20   43   88    -1    -1<\n>
ADC_LINE(3):  7  31  131  528    -1    -1<\n>
ADC_LINE(4):  7  32  132  535    -1    -1<\n>
ADC_LINE(5):  7  33  133  518    -1    -1<\n>
...

This is the output from current master:

main(): This is RIOT! (Version: 2024.04-devel-2099-gcdceb)<\n>
<\n>
RIOT ADC peripheral driver test<\n>
<\n>
This test will sample all available ADC lines once every 100ms with<\n>
a 10-bit resolution and print the sampled results to STDIO<\n>
<\n>
<\n>
Successfully initialized ADC_LINE(0)<\n>
Successfully initialized ADC_LINE(1)<\n>
Successfully initialized ADC_LINE(2)<\n>
Successfully initialized ADC_LINE(3)<\n>
Successfully initialized ADC_LINE(4)<\n>
Successfully initialized ADC_LINE(5)<\n>
ADC_LINE(0): 17<\n>
ADC_LINE(1): 1023<\n>
ADC_LINE(2): 169<\n>
ADC_LINE(3): 134<\n>
ADC_LINE(4): 123<\n>
ADC_LINE(5): 129<\n>
ADC_LINE(0): 14<\n>
ADC_LINE(1): 1023<\n>
ADC_LINE(2): 167<\n>
ADC_LINE(3): 126<\n>
ADC_LINE(4): 123<\n>
ADC_LINE(5): 126<\n>
ADC_LINE(0): 14<\n>
ADC_LINE(1): 1023<\n>
ADC_LINE(2): 169<\n>
ADC_LINE(3): 129<\n>
ADC_LINE(4): 121<\n>
ADC_LINE(5): 123<\n>
...

Issues/PRs references

See also #20780.

@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework labels Feb 18, 2025
Copy link
Copy Markdown
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changes are straightforward enough and confirmed to work as expected on a BOARD=nrf52840dk.

@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 20, 2025
@mguetschow mguetschow enabled auto-merge February 20, 2025 10:07
@riot-ci
Copy link
Copy Markdown

riot-ci commented Feb 20, 2025

Murdock results

✔️ PASSED

1cb67ee tests/adc: always test all resolutions

Success Failures Total Runtime
15 0 15 01m:25s

Artifacts

@mguetschow mguetschow added this pull request to the merge queue Feb 20, 2025
Merged via the queue into RIOT-OS:master with commit 88f2e45 Feb 20, 2025
27 checks passed
@crasbe
Copy link
Copy Markdown
Contributor Author

crasbe commented Feb 20, 2025

That was quick, thank you :)

@crasbe crasbe deleted the pr/adc_test branch February 20, 2025 10:13
@mguetschow mguetschow added this to the Release 2025.04 milestone Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: doc Area: Documentation Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants