Skip to content

[boards] Fix off-by-one in SysTick cyclesPerTick#40

Open
SAY-5 wants to merge 1 commit into
wolfSSL:mainfrom
SAY-5:fix-systick-reload-off-by-one
Open

[boards] Fix off-by-one in SysTick cyclesPerTick#40
SAY-5 wants to merge 1 commit into
wolfSSL:mainfrom
SAY-5:fix-systick-reload-off-by-one

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 12, 2026

Fixes #38.

Cortex-M SysTick reloads every LOAD + 1 cycles, so cyclesPerTick must be clock / ticks_per_second - 1 to produce the intended period. All ten board configs were one cycle high, causing the 1 kHz tick to run slightly slow.

Applied the maintainer-suggested fix (subtract 1 in each board config) rather than baking the offset into systick.c, to preserve the "cyclesPerTick" naming and keep RVR writes literal.

@AlexLanzano AlexLanzano self-assigned this May 16, 2026
@AlexLanzano
Copy link
Copy Markdown
Member

Hey @SAY-5,

Thank you so much for the contribution. I just merged some changes that caused some conflicts in your PR. The SysTick device initialization has moved to the board.h instead of the board.c now so it should be a quick fix for you.

Also, prior to merging this you will need to sign the wolfSSL contributor agreement. It's a quick process, just send an email to support at wolfssl dot com to get started. Please include this PR number and tell us about your project!

@SAY-5 SAY-5 force-pushed the fix-systick-reload-off-by-one branch from ad47719 to d5b5b02 Compare May 18, 2026 23:29
@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 18, 2026

Thanks for the heads up. Rebased onto main and moved the off-by-one fix into the WHAL_CFG_SYSTICK_DEV macro in each board.h. I'll email support to get the contributor agreement signed.

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

Successfully merging this pull request may close these issues.

Systick reload value off by one

2 participants