32-bit ICU

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Posts: 25
Joined: Tue Feb 25, 2014 10:24 am
Been thanked: 2 times

32-bit ICU

Postby plyatov » Mon Feb 01, 2016 4:42 pm

Dear all,

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.

Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 2 guests