Skip to content

tests: drivers: uart: baudrate_test: Improve accuracy measurement - #28455

Merged
nordic-piks merged 2 commits into
nrfconnect:mainfrom
nordic-krch:uart_baudrate_test
May 4, 2026
Merged

tests: drivers: uart: baudrate_test: Improve accuracy measurement#28455
nordic-piks merged 2 commits into
nrfconnect:mainfrom
nordic-krch:uart_baudrate_test

Conversation

@nordic-krch

Copy link
Copy Markdown
Contributor

Test was reporting high deviation 17-25% which seemed high. Such measurement inaccuracy was due to 3 reasons:

  • using gpio Zephyr API for reading pin state which is twice longer than using GPIO HAL
  • assumption that stop bits are also 0 and should be included in the measurement. UART stop bits are 1 so they should not be included
  • starting UART transfer and then starting the measurement. For high baudrates beginning of the byte was not included in the measurement as first gpio read was already 0.

All issues have been fixed:

  • Reduced number of bits in the frame (biggest gain).
  • Using GPIO HAL for reading the input - sampling frequency is doubled.
  • Transferring 2 bytes and measuring the second byte which improved accuracy for higher baudrates.

Additionally, reduced number of repeats from 10 to 3 to shorten the test.

@nordic-krch
nordic-krch requested review from a team as code owners April 29, 2026 12:11
@nordic-krch nordic-krch changed the title tests: drivers: uart: baudrate_test: Iprove accuracy measurement tests: drivers: uart: baudrate_test: Improve accuracy measurement Apr 29, 2026
@nordic-krch
nordic-krch force-pushed the uart_baudrate_test branch 2 times, most recently from 7c5b06d to 854ce59 Compare April 29, 2026 12:18
@NordicBuilder

NordicBuilder commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

CI Information

To view the history of this post, click the 'edited' button above
Build number: 2

Inputs:

Sources:

sdk-nrf: PR head: a24ca615f01723a65d8fc6f75b79b511a8693fa9

more details

sdk-nrf:

PR head: a24ca615f01723a65d8fc6f75b79b511a8693fa9
merge base: 01c741a64db9181ca9914d35efc6bc0ef98003ce
target head (main): 01c741a64db9181ca9914d35efc6bc0ef98003ce
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (2)
tests
│  ├── drivers
│  │  ├── uart
│  │  │  ├── uart_baudrate_test
│  │  │  │  ├── Kconfig
│  │  │  │  ├── src
│  │  │  │  │  │ main.c

Outputs:

Toolchain

Version: 53ac68dd62
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:53ac68dd62_5ea73affbf

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 16
  • ✅ Integration tests
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_mosh
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-audio
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-wifi

Note: This message is automatically posted and updated by the CI

@github-actions

Copy link
Copy Markdown

You can find the documentation preview for this PR here.

Remove unused parameter for the test function.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Test was reporting high deviation 17-25% which seemed high.
Such measurement inaccuracy was due to 3 reasons:
- using gpio Zephyr API for reading pin state which is twice longer
than using GPIO HAL
- assumption that stop bits are also 0 and should be included in the
measurement. UART stop bits are 1 so they should not be included
- starting UART transfer and then starting the measurement. For
high baudrates beginning of the byte was not included in the
measurement as first gpio read was already 0.

All issues have been fixed:
- Reduced number of bits in the frame (biggest gain).
- Using GPIO HAL for reading the input - sampling frequency is
doubled.
- Transferring 2 bytes and measuring the second byte which improved
accuracy for higher baudrates.

Additionally, reduced number of repeats from 10 to 3 to shorten
the test.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
@nordic-krch nordic-krch added the backwards-compatible PR doesnt break code, Kconfig, or DTS. I.e no changes needed for customers to port their application label Apr 29, 2026
@nordic-krch nordic-krch added this to the 3.4.0 milestone Apr 29, 2026
@nordic-piks
nordic-piks merged commit 466a0b0 into nrfconnect:main May 4, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards-compatible PR doesnt break code, Kconfig, or DTS. I.e no changes needed for customers to port their application no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants