support for HSI48 in stm32l4xx Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

support for HSI48 in stm32l4xx

Post by geoffrey.brown »

here's a patch to enable the HSI48 in the stm32l4 port (BTW, I tried to attach a file, but I couldn't find a "valid" extension")

Index: os/hal/ports/STM32/STM32L4xx/hal_lld.c
===================================================================
--- os/hal/ports/STM32/STM32L4xx/hal_lld.c (revision 11116)
+++ os/hal/ports/STM32/STM32L4xx/hal_lld.c (working copy)
@@ -194,6 +194,14 @@
; /* Wait until HSI is stable. */
#endif

+#if STM32_HSI48_ENABLED
+ /* HSI48 activation.*/
+ RCC->CCIPR |= RCC_CCIPR_CLK48SEL;
+ RCC->CRRCR |= RCC_CRRCR_HSI48ON;
+ while (!(RCC->CRRCR & RCC_CRRCR_HSI48RDY))
+ ; /* Waits until HSI48 is stable. */
+#endif
+
#if STM32_HSE_ENABLED
#if defined(STM32_HSE_BYPASS)
/* HSE Bypass.*/
Index: os/hal/ports/STM32/STM32L4xx/hal_lld.h
===================================================================
--- os/hal/ports/STM32/STM32L4xx/hal_lld.h (revision 11116)
+++ os/hal/ports/STM32/STM32L4xx/hal_lld.h (working copy)
@@ -72,6 +72,7 @@
* @{
*/
#define STM32_HSI16CLK 16000000 /**< High speed internal clock. */
+#define STM32_HSI48CLK 48000000 /**< 48MHz speed internal clock.*/
#define STM32_LSICLK 32000 /**< Low speed internal clock. */
/** @} */

@@ -363,6 +364,13 @@
#endif

/**
+ * @brief Enables or disables the HSI48 clock source.
+ */
+#if !defined(STM32_HSI48_ENABLED) || defined(__DOXYGEN__)
+#define STM32_HSI48_ENABLED FALSE
+#endif
+
+/**
* @brief Enables or disables the LSI clock source.
*/
#if !defined(STM32_LSI_ENABLED) || defined(__DOXYGEN__)
@@ -2001,7 +2009,11 @@
* @brief 48MHz clock frequency.
*/
#if (STM32_CLK48SEL == STM32_CLK48SEL_NOCLK) || defined(__DOXYGEN__)
+#if (STM32_HSI48_ENABLED)
+#define STM32_48CLK STM32_HSI48CLK
+#else
#define STM32_48CLK 0
+#endif
#elif STM32_CLK48SEL == STM32_CLK48SEL_PLLSAI1
#define STM32_48CLK (STM32_PLLSAI1VCO / STM32_PLLSAI1Q_VALUE)
#elif STM32_CLK48SEL == STM32_CLK48SEL_PLL
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: support for HSI48 in stm32l4xx

Post by Giovanni »

Thanks, I will review and merge this during weekend. I don't have HW for tests right now.

giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: support for HSI48 in stm32l4xx

Post by Giovanni »

Hi,

Support for HSI48 has been added but not tested, the implementation is a bit different from the one proposed.

Giovanni
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: support for HSI48 in stm32l4xx

Post by geoffrey.brown »

I updated to the latest repo and tested a design with CRS and the latest HSI48 support. The changes work fine.

Thanks !

Geoffrey
Post Reply