in the ChibiOS_16.1.2, I have found a bug at icu_lld.c.
If we use 32-bit timers like TIM2 or TIM5, then they are not able to measure long pulses. The ARR register overflows too early.
So, here is a small patch which resolve this issue.
Code: Select all
--- a/ChibiOS_16.1.2/os/hal/ports/STM32/LLD/TIMv1/icu_lld.c
+++ b/ChibiOS_16.1.2/os/hal/ports/STM32/LLD/TIMv1/icu_lld.c
@@ -517,7 +517,7 @@
((psc + 1) * icup->config->frequency) == icup->clock,
"invalid frequency");
icup->tim->PSC = psc;
- icup->tim->ARR = 0xFFFF;
+ icup->tim->ARR = 0xFFFFFFFF;
if (icup->config->channel == ICU_CHANNEL_1) {
/* Selected input 1.