Skip to main content
RZ_it
Associate II
February 14, 2020
Question

I2C2 stuck in timeout on STM32L4S9

  • February 14, 2020
  • 4 replies
  • 2667 views

HW situation is:

I2C2_SCL on PB10 (pin L4)

I2C2_SDA on PB11 (pin M4)

Both have a pull-up resistor of 18K.

The sensor attached to these lines is removed, so nothing is connected.

This is not a dev-board but our own design.

I have generated code through STMcubeMX (version 5.4.0).

0690X00000DAZUhQAP.png

0690X00000DAZUwQAP.png

Using the internal clock as a source:

0690X00000DAZUXQA5.png

I have added to the while loop in main:

status = HAL_I2C_Mem_Read(&hi2c2, 0xA0, 0x0F, I2C_MEMADD_SIZE_8BIT, &id, 2, 100);

The program gets stuck at:

static HAL_StatusTypeDef I2C_RequestMemoryRead(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout, uint32_t Tickstart)
{
 I2C_TransferConfig(hi2c, DevAddress, (uint8_t)MemAddSize, I2C_SOFTEND_MODE, I2C_GENERATE_START_WRITE);
 
 /* Wait until TXIS flag is set */
 if (I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, Tickstart) != HAL_OK)
 {
 return HAL_ERROR; //<=== we end-up here
 }
 

And nothing happens on the SCL line, no clock signal. The SDA line is pulled down.

We also tried:

status = HAL_I2C_Master_Transmit(&hi2c2, 0x40, &id, 2, 100);

Same result.

It is consistent on several different boards.

Any suggestions? Thanks.

This topic has been closed for replies.

4 replies

berendi
Principal
February 14, 2020

> Both have a pull-up resistor of 18K.

That would be a bit weak, do you mean 1.8K (1800 Ω) ?

(I can't say anything about the code, I could never bring up I2C with CubeMX. Perhaps you can try it using the register interface instead, as documented in the reference manual. That usually works, except of course when the pullup is too weak.)

RZ_it
RZ_itAuthor
Associate II
February 21, 2020

Just a quick answer, Thanks for your suggestion we are working on it. I'll let you know if it works.

ebce3
Associate
October 16, 2020

RZ, did you ever solve your problem? I have a very similar problem to yours (with 4.7K pull-up resistors, SDA remains unchanged at 1.22V instead of SCL) and your solution may apply to my problem, Thanks.

RZ_it
RZ_itAuthor
Associate II
October 18, 2020

Yes, but it is a bit embarrassing to admit. The sensor device was removed but the address selection resistor not. And the address selection resistor was connected to the SDA line, pulling it down (address selection resistor had a lower value then the line pull-up resistors). Making the processor belief the line is not free, hence the time-out. So I decreased the line pull-up resistors and increased the address selection resistor. Hope this helps.