Mbed-os: I2C slave bug - strech functionality

Created on 6 May 2018  路  13Comments  路  Source: ARMmbed/mbed-os

Description

Type: Bug

  • Related issue: #abc
  • Priority: Minor

Bug

Target
stm32f4

Toolchain:
IAR

Toolchain version:

mbed-cli version:
(mbed --version)

mbed-os sha:
(git log -n1 --oneline)

I am using my stm32f4 microcontroller as an i2c slave for the first time.
At the begining, I used the example of i2c slave from I2CSlave.h.
The I2C master did not recieve the message sent by the i2c slave, so I used my scope to see the clk and data.
I noticed that the slave (my microcontroller stm32f4) is pulling down the clk when he recieves a read massage.
Looking at the datasheet and the registers made I saw that the NOSTRETCH register is disabled as defualt in i2c_frequency() at i2c_api.c
Changing the register in the fuction to enable solved my problem.
I would like to know why isn't there an api for the register and why is it disabled as default?

IOTOSM-2201 DONE mirrored bug

All 13 comments

@ARMmbed/team-st-mcd Please review
[Mirrored to Jira]

I would like to know why isn't there an api for the register

What do you mean by "register" ? An API to access any MCU register ? or in your case an API to control the I2C stretch functionality ? If this is the last case, then there is no possibility in the mbed API to control it.

why is it disabled as default?

As there is no possibility in the mbed API to control it, we had to make a choice. But it is very simple to change it and disable the strech per default. But I don't know which impact it could have on all I2C devices connected ?

and @0xc0170 for me it is not a bug :smile:
[Mirrored to Jira]

After internal discussion, we think the best thing would be to have an API in mbed to change this stretch mode. For example in i2c_init or create a new method set_stretchmode ?
[Mirrored to Jira]

@bulislaw @donatieng @ithinuel See answer from @bcostm above. Also @0xc0170 - is this a bug or feature request?
[Mirrored to Jira]

The stretch mode is basically a flow control technique that is sensible to me to have enabled by default.
Introducing a way to disable such feature could be part of the work @scartmell-arm is doing on I虏C hal API : #7834
[Mirrored to Jira]

@screamerbg
As recommended by @ithinuel the stretch mode is indeed enabled by default on STM32 platforms s- to there is no bug in STM32.
As @YarivCol needs to disable it (probably the master device in the use case does not support stretch mode), then the point needs to be addressed first @ MBED API level to provide the way to disable it.
Can you update the ticket labels accordingly (e.g; removing device:st )
[Mirrored to Jira]

I would also either change the title or create a new one to specifically request an improvement in mbed API to disable the stretch mode.
[Mirrored to Jira]

Internal Jira reference: https://jira.arm.com/browse/IOTPART-6061

Can you please remove the devices:st label ? Because the enhancement to change the stretch mode in mbed API is for all the targets and not only ST ones.

@0xc0170 removed the [devices: st]
@elm3 added the [devices: st]

Could you correct the label and remove st device ?

Removed as this is generic issue

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2201

I would also either change the title or create a new one to specifically request an improvement in mbed API to disable the stretch mode.

+1, lets get a new feature request on the forum (not here as it's not technical issue but a new feature request). I'll close this one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccchang12 picture ccchang12  路  4Comments

DuyTrandeLion picture DuyTrandeLion  路  3Comments

bulislaw picture bulislaw  路  3Comments

davidantaki picture davidantaki  路  3Comments

1domen1 picture 1domen1  路  3Comments