stm32f4xx_hal_driver icon indicating copy to clipboard operation
stm32f4xx_hal_driver copied to clipboard

RCC_I2SCLKSOURCE_EXT has wrong value

Open leodicarpaccio opened this issue 2 years ago • 2 comments

The issue is really simple : in stm32f4xx_hal_rcc_ex.h, the value of RCC_I2SCLKSOURCE_EXT is wrong.

  • RCC_I2SCLKSOURCE_EXT must be equal to RCC_CFGR_I2SSRC (0x00800000) instead of 0x00000001.
  • __HAL_RCC_I2S_CONFIG macro must be corrected also as follow : #define __HAL_RCC_I2S_CONFIG(__SOURCE__) (MODIFY_REG(RCC->CFGR, RCC_CFGR_I2SSRC, (__SOURCE__)))

In stm32f4xx_hal_rcc_ex.c, this issue creates bugs everywhere __HAL_RCC_GET_I2S_SOURCE() is called and returned value compared to RCC_I2SCLKSOURCE_EXT

leodicarpaccio avatar May 30 '22 10:05 leodicarpaccio

Hi @leodicarpaccio,

First, thank you for your contribution.

The first point, the value of RCC_CFGR_I2SSRC must be 0x00000001 and not 0x00800000. Indeed, the purpose of this value is to set the bit RCC_CFGR_I2SSRC through the macro __HAL_RCC_I2S_CONFIG(RCC_I2SCLKSOURCE_EXT) .

Hence, The value #define RCC_I2SCLKSOURCE_EXT 0x00000001U is defined for a specific use purpose and is not the bit definition of RCC_CFGR_I2SSRC .

I tested this macro __HAL_RCC_I2S_CONFIG(RCC_I2SCLKSOURCE_EXT) with both proposals (0x00000001, 0x00800000) and checked that the bit RCC_CFGR_I2SSRC is only set when RCC_I2SCLKSOURCE_EXT is 0x00000001U

https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/6ea96e3bee7629552b26d92e96c2e64217bebfea/Inc/stm32f4xx_hal_rcc_ex.h#L527-L530

The second point, I think that you are confused between the Reference manual [(STM32F405/415, STM32F407/417, STM32F427/437) and STM32F429/439]

(https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf)) and (STM32F410)

In the first one it’s true that the I2SSCR bit is configured in RCC_CFGR register

image https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/6ea96e3bee7629552b26d92e96c2e64217bebfea/Inc/stm32f4xx_hal_rcc_ex.h#L6092-L6115

But in STM32F410 is configured in RCC_DCKCFGR

image https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/6ea96e3bee7629552b26d92e96c2e64217bebfea/Inc/stm32f4xx_hal_rcc_ex.h#L6597-L6621

With regards,

RJMSTM avatar Oct 03 '22 09:10 RJMSTM

Hello @RJMSTM,

Thanks for your detailed description but there is something I didn't get. As it is in stm32f4xx_hal_rcc_ex.c, many times the macro __HAL_RCC_GET_I2S_SOURCE() is called. The macro returned one of these values :

  • on STM32F405/415/407/417/427/437/429/439
    • 0x00000000
    • 0x00800000
  • on STM32F410:
    • 0x00000000
    • 0x02000000
    • 0x04000000

But just after this macro call, these values are compared directly with :

  • on STM32F405/415/407/417/427/437/429/439 :
    • 0x00000000 (=RCC_I2SCLKSOURCE_PLLI2S)
    • 0x00000001 (=RCC_I2SCLKSOURCE_EXT)
  • on STM32F410 :
    • 0x00000000 (=RCC_I2SAPBCLKSOURCE_PLLR)
    • 0x02000000 (=RCC_I2SAPBCLKSOURCE_EXT)
    • 0x04000000 (=RCC_I2SAPBCLKSOURCE_PLLSRC)

So for STM32F405/415/407/417/427/437/429/439 there is obviously a bug when comparing to RCC_I2SCLKSOURCE_EXT. Regards

leodicarpaccio avatar Oct 05 '22 07:10 leodicarpaccio

Hello,

Any update about this bug ? Please check my previous message.

Regards

leodicarpaccio avatar Mar 16 '23 10:03 leodicarpaccio

Hello @leodicarpaccio Sorry for my tardy reply. I'm still investigating, I will back to you in the next few days.

BeST Regards, Rania

RJMSTM avatar Mar 16 '23 10:03 RJMSTM

Hello,

You can stop investigating : it have been corrected in the meantime by someone else the 2nd February, following my suggestion.

Regards,

leodicarpaccio avatar Mar 17 '23 12:03 leodicarpaccio

Fixed in commit 08d0be9e82e0348566cbefc55f567ffeb297c3c4

ALABSTM avatar Sep 05 '23 15:09 ALABSTM