-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Fix timer_elapsed() overflow issue for STM32F103 and other ChibiOS boards #7595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, while I do like the idea of fixing this sort of weird issue, my guess is that this affects a bunch of other stuff too.
It may be best to improve the core functionality, rather than just this call.
Eg, update the function in:
https://github.com/qmk/qmk_firmware/blob/b624f32f944acdc59dcb130674c09090c5c404cb/tmk_core/common/chibios/timer.c
The ATSAM and AVR timer.c's both use |
Makes sense! I didn't occur to me to look at other implementations. I'll move the TIMER_DIFF_16() from process_space_cadet() to elapsed() in timer.c |
Just commit and push to the same branch, and it will show up here :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Been testing on my planck rev6, and on my collide 39 with a proto-proton C, and seems to not cause any issues |
Thank you for your contribution! |
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
…ards (qmk#7595) * fixed strange space cadet timer owerflow on STM32F103 * Moved elapsed time fix to timer.c
Description
Space Cadet does not work on STM32F103 (BluePill). Specifically it works a couple of times, then it stops. There may be a deeper problem in timeout computation that I'm not able to fix (being a Java programmer). Basically after a couple of any key presses the timer_elapsed() starts returning large increments (the overflow variable in chibios/timer.c) gets stuck at 65535.
Adding TIMER_DIFF_16() to the comparison in perform_space_cadet() fixed the problem. I'm aware that it is probably not the "right" solution but it works for this case.
It is a simple change but I'm a little worried that I was not able to test the fix on any other architecture.
Types of Changes
Issues Fixed or Closed by This PR
Checklist