-
Notifications
You must be signed in to change notification settings - Fork 3k
STM stm_spi_api.c:spi_frequency has a bug with a -1 index into the baudrate_prescaler_table #3735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll take it ... |
Should be easy just to check if prescaler_rank is 0 than change it to 1. The question I have, is the max SPI clock rate according to spi_get_clock_freq is 40 Mhz according to spi_get_clock_freq(), using the 0 scale divides it by 2 which means 20 Mhz. Is this the max we can get from the SPI on the L4? I use a WinBond SPI Flash which can go as high as 104 Mhz, other models can go even up to 208 Mhz. |
hello - first of all, thanks for reporting the issue. As of now, the PCLK2 freq is set to 40 MHz, which leaves 20MHz as the highest SPI frequency. Though the PCLK2 could be increased from 40MHz to 80MHz (and spi from 20 to 40) by changing the below line with RCC_HCLK_DIV1 instead of RCC_HCLK_DIV2; I will have to check with by colleague @jeromecoutant to understand whether we can change the default setting. Until then, you can give it a try for your SPI flash usage. |
@helmut64 I tried to make the code more comprehensive as I pushed the fix. Please let me know if you can give it a try. |
It works now fine for me, see my comments in #3759 |
@helmut64 thank you for your prompt feedback ! Cheers |
@LMESTM sounds good to me. |
The problem occures e.g. on the STM32L4 when a 40 Mhz hz value is being used.
See file stm_spi_api.c:
With the 40000000 hz sample, the baudrate_prescaler_table is zero and initializes the Init.BaudRatePrescaler with random values. The previous hal implementation in spi_frequency file spi_api.c does not have this problem.
Regards Helmut
The text was updated successfully, but these errors were encountered: