I2S isn't working with external clock source

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

Moderator: RoccoMarco

Post Reply
Kosyak
Posts: 14
Joined: Tue Jul 22, 2014 3:22 am

I2S isn't working with external clock source

Post by Kosyak »

Found bug in ChibiOS HAL for STM32F4 - I2S peripheral isn't working when switched to external clock source (I2S_CKIN).

Diving into ChibiOS HAL sources shows me that STM32_I2SSRC macro (from mcuconf.h) used only for turning on PLLI2S, not for actual clock switching (I2SSRC bit in RCC_CFGR)

So here's trivial patch to fix this issue:

Code: Select all

diff --git a/os/hal/ports/STM32/STM32F4xx/hal_lld.c b/os/hal/ports/STM32/STM32F4xx/hal_lld.c
index ff9ff93..2911b49 100644
--- a/os/hal/ports/STM32/STM32F4xx/hal_lld.c
+++ b/os/hal/ports/STM32/STM32F4xx/hal_lld.c
@@ -245,7 +245,8 @@ void stm32_clock_init(void) {
 
   /* Other clock-related settings (dividers, MCO etc).*/
   RCC->CFGR = STM32_MCO2PRE | STM32_MCO2SEL | STM32_MCO1PRE | STM32_MCO1SEL |
-              STM32_RTCPRE | STM32_PPRE2 | STM32_PPRE1 | STM32_HPRE;
+              STM32_I2SSRC | STM32_RTCPRE | STM32_PPRE2 | STM32_PPRE1 |
+              STM32_HPRE;
 
   /* Flash setup.*/
 #if defined(STM32_USE_REVISION_A_FIX)

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

Re: I2S isn't working with external clock source

Post by Giovanni »

Hi,

Sorry, I forgot about this and it missed 3.0.3. It is fixed in the repository and will go in 3.0.4.

Thanks for the patch.

Giovanni
Post Reply