Page 1 of 1

support for HSI48 in stm32l4xx

Posted: Tue Dec 05, 2017 3:15 pm
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

Re: support for HSI48 in stm32l4xx

Posted: Tue Dec 05, 2017 3:43 pm
by Giovanni
Thanks, I will review and merge this during weekend. I don't have HW for tests right now.

giovanni

Re: support for HSI48 in stm32l4xx

Posted: Fri Dec 08, 2017 4:48 pm
by Giovanni
Hi,

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

Giovanni

Re: support for HSI48 in stm32l4xx

Posted: Mon Dec 11, 2017 7:22 pm
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