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.
geoffrey.brown
Posts: 24
Joined: Thu May 07, 2015 9:47 pm
Been thanked: 5 times

support for HSI48 in stm32l4xx  Topic is solved

Postby geoffrey.brown » Tue Dec 05, 2017 3:15 pm

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: 10341
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 231 times
Been thanked: 205 times
Contact:

Re: support for HSI48 in stm32l4xx

Postby Giovanni » Tue Dec 05, 2017 3:43 pm

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: 10341
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 231 times
Been thanked: 205 times
Contact:

Re: support for HSI48 in stm32l4xx

Postby Giovanni » Fri Dec 08, 2017 4:48 pm

Hi,

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

Giovanni

geoffrey.brown
Posts: 24
Joined: Thu May 07, 2015 9:47 pm
Been thanked: 5 times

Re: support for HSI48 in stm32l4xx

Postby geoffrey.brown » Mon Dec 11, 2017 7:22 pm

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

Thanks !

Geoffrey


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 1 guest