Skip to content

STM32: spi_frequency table index fix #3759

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

Merged
merged 1 commit into from
Feb 21, 2017
Merged

Conversation

LMESTM
Copy link
Contributor

@LMESTM LMESTM commented Feb 13, 2017

Description

This fix address issue #3735

In case of prescaler_rank was 0, a -1 index was being used,
which resulted in initialization of the Init.BaudRatePrescaler with
random values.

Now let's better check index and avoid -1 operation, so that prescaler_rank
can be only from 0 to "last_index".

Status

READY

Tested with various range of clock on L4 device, including max frequency as reported in the Issue

In case of prescaler_rank was 0, a -1 index was being used,
which resulted in initialization of the Init.BaudRatePrescaler with
random values.

Now let's better check index and avoid -1 operation, so that prescaler_rank
can be only from 0 to "last_index".
@sg- sg- added the needs: CI label Feb 13, 2017
@0xc0170
Copy link
Contributor

0xc0170 commented Feb 14, 2017

/morph test

@helmut64
Copy link
Contributor

I tested the new spi_frequency() function, it is now much cleaner, I tested it with my 40 Mhz example as well with the 100 kHz example. It works now as expected.
Regards Helmut

@bridadan
Copy link
Contributor

retest uvisor

@sg-
Copy link
Contributor

sg- commented Feb 17, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1631

Test failed!

@bridadan
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1640

All builds and test passed!

@sg- sg- merged commit 4b850e2 into ARMmbed:master Feb 21, 2017
@c1728p9
Copy link
Contributor

c1728p9 commented Feb 27, 2017

With this patch 100KHz no longer works on the Odin (NUCLEO_F439ZI) and NUCLEO_F429ZI. When the SDBlockDevice is used I get:

Couldn't set suitable SPI freq: request:100000, lowest:328125

@LMESTM
Copy link
Contributor Author

LMESTM commented Feb 28, 2017

@c1728p9 : I think this was already the case before. So you're requesting 100kHz which is a pretty low SPI frequency, and the lowest available frequency based on current clock configuration of F429ZI is 328125kHz (84MHz with 256 prescaler).

But maybe the error call in this case is a mistake, I think we could live with a warning (as this proved to work most of the time so far) ? May you try out with a warn() call instead of error() ?
https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/stm_spi_api.c#L311

Also have you raised an issue for it ?

thanks

@LMESTM
Copy link
Contributor Author

LMESTM commented Feb 28, 2017

@c1728p9
I submitted a new issue #3849 and will send corresponding PR

aisair pushed a commit to aisair/mbed that referenced this pull request Apr 30, 2024
Ports for Upcoming Targets


Fixes and Changes

3590: [NUC472/M453] Export IAR project and other bugfixes ARMmbed/mbed-os#3590
3740: STM32L4 HAL update for RTC Wake Up Timer ARMmbed/mbed-os#3740
3739: STM32F7 : remove multiple HSE_VALUE define value ARMmbed/mbed-os#3739
3759: STM32: spi_frequency table index fix ARMmbed/mbed-os#3759
3779: NCS36510: Fix the sporadic semaphore timing issue ARMmbed/mbed-os#3779
3806: NXP KL43Z/KL27Z: fix spi format bits check ARMmbed/mbed-os#3806
3814: NCS36510: I2C idle delay of 1us ARMmbed/mbed-os#3814
3803: Bug fix of initial value of interrupt edge in "gpio_irq_init" again ARMmbed/mbed-os#3803
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants