cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with I2C HAL in TouchGFX RTOS thread.

MM..1
Chief III

Hello, i see trouble with I2C 

HAL_I2C_Master_Transmit(&hi2c2, addr==0 ? I2C_ADDR_DACR : addr, Buff,3,5);

in project with TouchGFX RTOS i have two threads. One for GUI and second is this hw I2C.

On scope i see, that I2C sometimes (random) split send or receive with clock stretch and sometimes complete hang or skip bytes. How is right setup for use it in multitask envi?

Seems when thread block more as timeout in this cmd , then cmd skip bytes or...

Now on U5, but i mean issue is all HAL. And i ask some tips, except DMA and IT, this ofcourse can change situation.

3 REPLIES 3
TDK
Super User

A 5ms timeout is small, particularly if other interrupts or task switching is happening. Perhaps it is timing out. SCL stretching when the CPU hasn't sent data yet is expected.

 

Can you show scope traces where this happens?

Does the function return HAL_OK?

If you feel a post has answered your question, please click "Accept as Solution".

I mean timeout is ok , real 3 bytes in fast mode is around 65us. Use bigger timeout isnt solution. I need info how RTOS handle this. Example for priority equal and upper lower as GUI or second next threads...

If task switches away for 5ms, it's not enough. Evidence suggests that's happening.

If you feel a post has answered your question, please click "Accept as Solution".