hytech-racing / MCU

https://hytech-racing.github.io/MCU/index.html
GNU General Public License v3.0
0 stars 0 forks source link

overhaul SysTick to allow for better load distribution through time #77

Open Dopp-IO opened 5 months ago

Dopp-IO commented 5 months ago

Currently if too many systems write to the CAN bus on a single tick, packets get dropped. Although we can schedule things by frequency, we also want to be able to offset certain actions from each other so they don't overwhelm shared systems like the CAN bus.

Proposed fix is to remove triggers from SysTick and create a new function called derivedTick(period, offset) which will return true at the specified frequency but can be configured with offset to delay its activation.

E.g. derivedTick(10, 0) and derivedTick(10, 5) both tick at 100hz but the second call is offset by 5 ms.

It's called derived because its functionality should be derived from a high frequency counter (1khz counter?).