TIM16 & 17 do not support ICU but are in the driver Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
FXCoder
Posts: 267
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 106 times
Been thanked: 85 times

TIM16 & 17 do not support ICU but are in the driver  Topic is solved

Postby FXCoder » Sun Jul 05, 2020 3:17 am

Hi,
TIM16 & 17 have only one capture register and cannot support ICU.
To avoid confusion remove TIM17 & 17 timers from the driver.
Should probably be changed in the *.inc files as well?
--
Bob

Code: Select all

Index: os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.c
===================================================================
--- os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.c   (revision 13731)
+++ os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.c   (working copy)
@@ -143,22 +143,6 @@
 #endif
 
 /**
- * @brief   ICUD16 driver identifier.
- * @note    The driver ICUD16 allocates the timer TIM16 when enabled.
- */
-#if STM32_ICU_USE_TIM16 || defined(__DOXYGEN__)
-ICUDriver ICUD16;
-#endif
-
-/**
- * @brief   ICUD17 driver identifier.
- * @note    The driver ICUD17 allocates the timer TIM17 when enabled.
- */
-#if STM32_ICU_USE_TIM17 || defined(__DOXYGEN__)
-ICUDriver ICUD17;
-#endif
-
-/**
  * @brief   ICUD20 driver identifier.
  * @note    The driver ICUD20 allocates the timer TIM20 when enabled.
  */
@@ -432,18 +416,6 @@
 #endif /* !defined(STM32_TIM15_SUPPRESS_ISR) */
 #endif /* STM32_ICU_USE_TIM15 */
 
-#if STM32_ICU_USE_TIM16 || defined(__DOXYGEN__)
-#if !defined(STM32_TIM16_SUPPRESS_ISR)
-#error "TIM16 ISR not defined by platform"
-#endif /* !defined(STM32_TIM16_SUPPRESS_ISR) */
-#endif /* STM32_ICU_USE_TIM16 */
-
-#if STM32_ICU_USE_TIM17 || defined(__DOXYGEN__)
-#if !defined(STM32_TIM17_SUPPRESS_ISR)
-#error "TIM17 ISR not defined by platform"
-#endif /* !defined(STM32_TIM17_SUPPRESS_ISR) */
-#endif /* STM32_ICU_USE_TIM17 */
-
 #if STM32_ICU_USE_TIM20 || defined(__DOXYGEN__)
 #if !defined(STM32_TIM20_SUPPRESS_ISR)
 #error "TIM20 ISR not defined by platform"
@@ -551,18 +523,6 @@
   ICUD15.tim = STM32_TIM15;
 #endif
 
-#if STM32_ICU_USE_TIM16
-  /* Driver initialization.*/
-  icuObjectInit(&ICUD16);
-  ICUD16.tim = STM32_TIM16;
-#endif
-
-#if STM32_ICU_USE_TIM17
-  /* Driver initialization.*/
-  icuObjectInit(&ICUD17);
-  ICUD17.tim = STM32_TIM17;
-#endif
-
 #if STM32_ICU_USE_TIM20
   /* Driver initialization.*/
   icuObjectInit(&ICUD20);
@@ -774,30 +734,6 @@
     }
 #endif
 
-#if STM32_ICU_USE_TIM16
-    if (&ICUD16 == icup) {
-      rccEnableTIM16(true);
-      rccResetTIM16();
-#if defined(STM32_TIM16CLK)
-      icup->clock = STM32_TIM16CLK;
-#else
-      icup->clock = STM32_TIMCLK2;
-#endif
-    }
-#endif
-
-#if STM32_ICU_USE_TIM17
-    if (&ICUD17 == icup) {
-      rccEnableTIM17(true);
-      rccResetTIM17();
-#if defined(STM32_TIM17CLK)
-      icup->clock = STM32_TIM17CLK;
-#else
-      icup->clock = STM32_TIMCLK2;
-#endif
-    }
-#endif
-
 #if STM32_ICU_USE_TIM20
     if (&ICUD20 == icup) {
       rccEnableTIM20(true);
@@ -1025,18 +961,6 @@
     }
 #endif
 
-#if STM32_ICU_USE_TIM16
-    if (&ICUD16 == icup) {
-      rccDisableTIM16();
-    }
-#endif
-
-#if STM32_ICU_USE_TIM17
-    if (&ICUD17 == icup) {
-      rccDisableTIM17();
-    }
-#endif
-
 #if STM32_ICU_USE_TIM20
     if (&ICUD20 == icup) {
       rccDisableTIM20();
Index: os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.h
===================================================================
--- os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.h   (revision 13731)
+++ os/hal/ports/STM32/LLD/TIMv1/hal_icu_lld.h   (working copy)
@@ -458,14 +458,6 @@
 #error "TIM15 not present in the selected device"
 #endif
 
-#if STM32_ICU_USE_TIM16 && !STM32_HAS_TIM16
-#error "TIM16 not present in the selected device"
-#endif
-
-#if STM32_ICU_USE_TIM17 && !STM32_HAS_TIM17
-#error "TIM17 not present in the selected device"
-#endif
-
 #if STM32_ICU_USE_TIM17 && !STM32_HAS_TIM20
 #error "TIM20 not present in the selected device"
 #endif
@@ -484,9 +476,9 @@
     !STM32_ICU_USE_TIM9  && !STM32_ICU_USE_TIM10 &&                         \
     !STM32_ICU_USE_TIM11 && !STM32_ICU_USE_TIM12 &&                         \
     !STM32_ICU_USE_TIM13 && !STM32_ICU_USE_TIM14 &&                         \
-    !STM32_ICU_USE_TIM15 && !STM32_ICU_USE_TIM16 &&                         \
-    !STM32_ICU_USE_TIM17 && !STM32_ICU_USE_TIM20 &&                         \
-    !STM32_ICU_USE_TIM21 && !STM32_ICU_USE_TIM22
+    !STM32_ICU_USE_TIM15 && !STM32_ICU_USE_TIM17 &&                      \
+   !STM32_ICU_USE_TIM20 && !STM32_ICU_USE_TIM21 &&                   \
+   !STM32_ICU_USE_TIM22
 #error "ICU driver activated but no TIM peripheral assigned"
 #endif
 
@@ -595,22 +587,6 @@
 #endif
 #endif
 
-#if STM32_ICU_USE_TIM16
-#if defined(STM32_TIM16_IS_USED)
-#error "ICUD16 requires TIM16 but the timer is already used"
-#else
-#define STM32_TIM16_IS_USED
-#endif
-#endif
-
-#if STM32_ICU_USE_TIM17
-#if defined(STM32_TIM17_IS_USED)
-#error "ICUD17 requires TIM17 but the timer is already used"
-#else
-#define STM32_TIM17_IS_USED
-#endif
-#endif
-
 #if STM32_ICU_USE_TIM20
 #if defined(STM32_TIM20_IS_USED)
 #error "ICUD20 requires TIM20 but the timer is already used"
@@ -701,16 +677,6 @@
 #error "Invalid IRQ priority assigned to TIM15"
 #endif
 
-#if STM32_ICU_USE_TIM16 && !defined(STM32_TIM16_SUPPRESS_ISR) &&            \
-    !OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM16_IRQ_PRIORITY)
-#error "Invalid IRQ priority assigned to TIM16"
-#endif
-
-#if STM32_ICU_USE_TIM17 && !defined(STM32_TIM17_SUPPRESS_ISR) &&            \
-    !OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM17_IRQ_PRIORITY)
-#error "Invalid IRQ priority assigned to TIM17"
-#endif
-
 #if STM32_ICU_USE_TIM20 && !defined(STM32_TIM20_SUPPRESS_ISR) &&            \
     !OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM20_IRQ_PRIORITY)
 #error "Invalid IRQ priority assigned to TIM20"
@@ -933,14 +899,6 @@
 extern ICUDriver ICUD15;
 #endif
 
-#if STM32_ICU_USE_TIM16 && !defined(__DOXYGEN__)
-extern ICUDriver ICUD16;
-#endif
-
-#if STM32_ICU_USE_TIM17 && !defined(__DOXYGEN__)
-extern ICUDriver ICUD17;
-#endif
-
 #if STM32_ICU_USE_TIM20 && !defined(__DOXYGEN__)
 extern ICUDriver ICUD20;
 #endif

User avatar
Giovanni
Site Admin
Posts: 12944
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 731 times
Been thanked: 609 times
Contact:

Re: TIM16 & 17 do not support ICU but are in the driver

Postby Giovanni » Mon Jul 06, 2020 6:31 pm

Hi,

Fixed bug #1111.

While working on this I also found another problem in TIMv1 ICU (wrong preprocessor checks), fixed that as well.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests