cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 HAL I2C driver not working anymore after update

onderdelen
Associate II

I recently update my STM32L4 HAL library from 1.9 to 1.13.  After that, using the

 
HAL_I2C_Mem_Write_IT
 
function, I got stuck in an error routine because TCR flag was set and that shouldn't happen:
 
Schermafbeelding 2023-07-02 om 17.08.20.png
 
 
 
 
 
 
 
When I looked at the changes in the HAL library, I saw that the HAL function changed the transfermethod to RELOAD
instead of the AUTOEND that it used in the old library version when the amount of bytes was less than 256:
Schermafbeelding 2023-07-02 om 17.06.53.png
 
I think this is a mistake. The I2C transfer should always be using AUTOEND
unless the amount of bytes exceeds 255.
 
Am I overlooking something here?
 
Ewout Boks
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @onderdelen , 

Thank you for reporting this issue.
It will be fixed soon.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
onderdelen
Associate II

I applied a fix to the driver by setting the XferSize member variable to 0. Doing this made the ISR routine perform without any errors, and my application runs again without problems.:

Schermafbeelding 2023-07-02 om 17.43.08.pngI reckon this fix, if valid, should also be applied to the the HAL_I2C_Mem_Read_IT function.

Perhaps someone from ST can comment on this?

With best regards,

 

Ewout Boks

Foued_KH
ST Employee

Hello @onderdelen , 

Thank you for reporting this issue.
It will be fixed soon.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

onderdelen
Associate II

Hi,

Thanks for your reply. My take on it is that the XferSize variable holds a value after an I2C transfer. Then, when doing the next transfer the old value would be in the way and interfere with the new setup in the HAL function, which splits the transfer in a few parts using the RELOAD feature of the I2C hardware. The reset of XferSize to 0 is required.