ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.63k stars 2.96k forks source link

STM32F4: FMPI2C doesn't work #15413

Open mikrodust-henrikp opened 1 year ago

mikrodust-henrikp commented 1 year ago

Description of defect

When trying to use I2C with pins connected to FMPI2C1 on an STM32F412 the code compiles without warnings and no assert is raised while trying to communicate over said I2C bus, but no output is observed on the pins configured.

Debugging a bit more, I've noted that RCC, clocks, pin states, etc are correctly set up, but it seems that the I2C HAL API in mbed doesn't work for FMPI2C. Noted also that it fails silently without warning. Just doesn't do anything.

I tested by calling the HAL_FMPI2C_Init() and HAL_FMPI2C_Master_Transmit() functions with appropriate settings and it then works, so there is nothing wrong with the HAL or the pinmap.

Target(s) affected by this defect ?

STM32F4

Toolchain(s) (name and version) displaying this defect ?

GCC

What version of Mbed-os are you using (tag or sha) ?

6.17.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli2

How is this defect reproduced ?

Connect I2C bus to FMPI2C1 on an STM32F4, try to use it via the I2C interface.

mbedmain commented 1 year ago

@mikrodust-henrikp thank you for raising this issue.Please take a look at the following comments:

What toolchain(s) are you using?

NOTE: If there are fields which are not applicable then please just add 'n/a' or 'None'. This indicates to us that at least all the fields have been considered. Please update the issue header with the missing information.

mikrodust-henrikp commented 1 year ago

Maybe it's known, since I found mentions regarding this in the forums: https://forums.mbed.com/t/not-working-fmpi2c1-stm32f446re-nucleo-f446re-fmpi2c/7890

But it seems wrong that it fails silently, and of course would be even better if it actually worked.

0xc0170 commented 1 year ago

@jeromecoutant would you know about FMPI2C1 ?

jeromecoutant commented 1 year ago

@jeromecoutant would you know about FMPI2C1 ?

No... maybe this is why it has not been supported yet with mbed-os :-)

jeromecoutant commented 1 year ago

I suppose I should remove all FMPI2C_1 pins from https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F412xG/TARGET_NUCLEO_F412ZG/PeripheralPins.c#L84-L116

mikrodust-henrikp commented 1 year ago

We have a custom target and the STM32_gen_PeripheralPins.py will happily generate FMPI2C definitions in PeripheralPins. So..maybe solved for some targets that way, but not all. Also the https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/i2c_api.c has some clock setup and things related to FMPI2C which sort of indicates that it should work, but maybe it should be made to fail with MBED_ERROR or something if FMPI2C1 is encountered, or something.

Even better would be to fix i2c_read/i2c_write to use the fmpi2c HAL API that seems to be working just fine, but I don't know how well that'll work with the i2c_byte_read et al..if at all.