Skip to content

STM32 I2C driver "repeated start" issue #583

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

Closed
jmchiappa opened this issue Jul 29, 2019 · 5 comments · Fixed by #748
Closed

STM32 I2C driver "repeated start" issue #583

jmchiappa opened this issue Jul 29, 2019 · 5 comments · Fixed by #748
Labels
enhancement New feature or request

Comments

@jmchiappa
Copy link
Contributor

Hello,

I'm trying to connect to the MMA8451 accelerometer. This chip requires an I2C driver with repeated-start feature enabled to discuss with.
I've a NUCLEO-F411RE, lib 1.6.1 and no repeated start is generated due to some low level limitations.
Let me explain:
XferOptions variable is always set to I2C_NO_OPTION_FRAME in the HAL_I2C_Transmit_IT. So, once the Xfer is completed, it fires I2C_MasterTransmit_TXE. As the following condition is always false (stm32f4xx_hal_i2c.c):
if ((CurrentXferOptions != I2C_FIRST_AND_LAST_FRAME) && (CurrentXferOptions != I2C_LAST_FRAME) && (CurrentXferOptions != I2C_NO_OPTION_FRAME))
a STOP will be generated (line 5025):

      /* Disable EVT, BUF and ERR interrupt */
      __HAL_I2C_DISABLE_IT(hi2c, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR);

      /* Generate Stop */
      SET_BIT(hi2c->Instance->CR1, I2C_CR1_STOP);

Does someone can confirm ?
How could we override XferOptions by setting to I2C_LAST_FRAME_NO_STOP ?
Ok, I understand that it's not directly related to the framework by itself, but I observed that I2C driver is really different regarding the variant.
In other word, by using TwoWire::endTransmission(false), it should not send a STOP condition (instead of UNUSED(endStop) ).

Thank you,
jean-marc

@fpistm
Copy link
Member

fpistm commented Jul 30, 2019

Hi Jean-Marc,
thanks for the report. Will try to investigate when got a time slot. (will be on vacation soon)
Maybe @LMESTM will have a look when he came back from vacation.

@jmchiappa
Copy link
Contributor Author

Hi Frédéric,
Thank you for your reply.
After deeper investigation, it seems that HAL_I2C_Master_Seq_Transmit_IT is more relevant to generate a 'repeated-start' as XferOptions is passed in argument list.
Curiously, this function is called HAL_I2C_Master_Sequential_Transmit_IT in F0,F1,F2,F3 series but it's correctly bind in legacy file.
I'll have a try as soon as I can (in holidays soon too).

Enjoy your holidays !

@fpistm
Copy link
Member

fpistm commented Jul 31, 2019

Thanks, enjoy too.

The function has been renamed in newer STM32CubeFW Release for or MISRA-C 2012 compliancy:
See the Release_Notes.html

I guess at term all series will be renamed. The next cube update add this too for some of this series, see #566.

@fpistm
Copy link
Member

fpistm commented Sep 13, 2019

Fixed by #590

@fpistm fpistm closed this as completed Sep 13, 2019
@fpistm fpistm reopened this Sep 23, 2019
@fpistm
Copy link
Member

fpistm commented Sep 23, 2019

During non reg tests for 1.7.0 release found issue with STM32 F2 and F4 related to #590.
So I've reverted it to perform further investigation.

fpistm pushed a commit to fpistm/Arduino_Core_STM32 that referenced this issue Oct 31, 2019
@fpistm fpistm mentioned this issue Oct 31, 2019
@fpistm fpistm added enhancement New feature or request and removed New feature labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants