L432KC i2cMasterTransmit freezes

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Raul
Posts: 32
Joined: Thu Aug 13, 2015 5:15 pm
Has thanked: 3 times
Been thanked: 1 time

L432KC i2cMasterTransmit freezes

Postby Raul » Thu Jun 14, 2018 11:21 pm

I'm having some hard time trying to run I2C transactions with a STM32L432KC, from the first call I do to i2cMasterTransmit the application seems to freeze, nothing seems to run at the thread level and there aren't any assertions have debug checks enabled.
Before I proceed I'd like to point out that I've been through the recommended troubleshooting guide and that I can run the same code with exactly the same I2C slave using a STM32L476RG instead with no issues at all.

Under Chibios 18.2.0, using I2C1, with no other peripherals enabled, these are the pertinent settings I have:

Code: Select all

/*
 * I2C driver system settings.
 */
#define STM32_I2C_USE_I2C1                  TRUE
#define STM32_I2C_USE_I2C3                  FALSE
#define STM32_I2C_BUSY_TIMEOUT              50
#define STM32_I2C_I2C1_RX_DMA_STREAM        STM32_DMA_STREAM_ID(1, 7)
#define STM32_I2C_I2C1_TX_DMA_STREAM        STM32_DMA_STREAM_ID(1, 6)
#define STM32_I2C_I2C3_RX_DMA_STREAM        STM32_DMA_STREAM_ID(1, 3)
#define STM32_I2C_I2C3_TX_DMA_STREAM        STM32_DMA_STREAM_ID(1, 2)
#define STM32_I2C_I2C1_IRQ_PRIORITY         5
#define STM32_I2C_I2C3_IRQ_PRIORITY         5
#define STM32_I2C_I2C1_DMA_PRIORITY         3
#define STM32_I2C_I2C3_DMA_PRIORITY         3
#define STM32_I2C_DMA_ERROR_HOOK(i2cp)      osalSysHalt("DMA failure")


I managed to take a capture with a logic analyzer, this is produced by calling i2cMasterTransmit with 1 byte tx buffer and 3 bytes for the rx.
The write and cmd byte make it through, with the expected SCL clock, but when it is time to perform the start condition belonging to the 3 byte read, SCL remains permanently low until an application reset.

i2c_capture.png
i2c_capture.png (6.48 KiB) Viewed 129 times


Has anybody managed to run I2C transactions with a STM32L432KC?, I noticed there's support for a nucleo board based on that MCU.

Any suggestions regarding what I could do to debug this issue further will be appreciated.
I looked into i2c_lld_master_transmit_timeout and managed to trace the call down to I2Cv2/hal_i2c_lld.c:1139

Code: Select all

 
 /* Waits for the operation completion or a timeout.*/
  msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);


What I seem to gather there is because the timeout is INFINITE, this is deliberate, and the transaction never concludes threads don't run.

Thanks in advance,

Raul

User avatar
Giovanni
Site Admin
Posts: 10952
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 340 times
Been thanked: 281 times
Contact:

Re: L432KC i2cMasterTransmit freezes

Postby Giovanni » Fri Jun 15, 2018 7:43 am

Hi,

Hard to tell, if the thread stays in that function means that I2C ISR is not invoked.

You should verify GPIO pins setup.

Giovanni

User avatar
alex31
Posts: 217
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 8 times
Been thanked: 17 times
Contact:

Re: L432KC i2cMasterTransmit freezes

Postby alex31 » Fri Jun 15, 2018 8:35 am

Has anybody managed to run I2C transactions with a STM32L432KC?, I noticed there's support for a nucleo board based on that MCU.


Yes, i use stm32nucleol432 to drive i2c IMU (invensense 9250) without problem.

Do you use external pullup for scl/sda or do you rely on internal ones ?

are you sure of your timingr value ? (can be different on the two boards if the clock tree has not same configuration), cubemx helps to calculate timingr value.

Alexandre

Raul
Posts: 32
Joined: Thu Aug 13, 2015 5:15 pm
Has thanked: 3 times
Been thanked: 1 time

Re: L432KC i2cMasterTransmit freezes

Postby Raul » Fri Jun 15, 2018 2:55 pm

Hi Giovanny, Alex,

Thanks for your observations.

Hard to tell, if the thread stays in that function means that I2C ISR is not invoked.


That's a interesting point, I guess it makes sense that the Start and read operations wouldn't occur if that was the case? How can I double check that the interrupts are enabled?
I believe the GPIO configuration is correct, alternate enabled, etc. I've compared the *conf.h with the ones for the nucleo L432 demo and the settings are pretty much identical (Use same clock arrangement).

Do you use external pullup for scl/sda or do you rely on internal ones ?


I've tried with both (no external when using the internal) and have the same results.

are you sure of your timingr value ? (can be different on the two boards if the clock tree has not same configuration), cubemx helps to calculate timingr value.


Yep, good point. I checked that originally with Cubemx tool (timing = 0x10909CEC assuming 0 for falling and raising times, added 1000 rasiing and 40 falling in case of internal resistors) I'd assume that the register is correct during initialization as I get the 100 KHz ok.

I have just ordered a stm32nucleol432, it is worth to test it against that as the results would be very conclusive. I'll update.

Raul

Polux
Posts: 6
Joined: Thu Apr 28, 2016 11:52 am
Been thanked: 2 times

Re: L432KC i2cMasterTransmit freezes

Postby Polux » Fri Jun 15, 2018 3:27 pm

Hi,

I also used the Nucleo432, connected to 4 MCP23017 (I/O ports). I used external 2k2 resistors and connection was fairly easy.
But as I also used CAN, the STM32 is not running at full speed, due to timings problems when used with internal RC.

I will post the code when I go home.

Angelo

Raul
Posts: 32
Joined: Thu Aug 13, 2015 5:15 pm
Has thanked: 3 times
Been thanked: 1 time

Re: L432KC i2cMasterTransmit freezes

Postby Raul » Fri Jun 15, 2018 7:16 pm

Hi Angelo,

But as I also used CAN, the STM32 is not running at full speed, due to timings problems when used with internal RC.


Could you elaborate on that? With not running at full speed do you mean the I2C (at 400 KHz)? I'm also intending to use CAN, disable at this stage, what are the incompatibilities between I2C and CAN?

Thanks,

Raul


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 2 guests