cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L053 I2C size managment error

thierry2
Associate
Posted on November 04, 2014 at 17:13

Hello everybody.

I hope someone could help...

I work with a STM32L053 and should communicate over I2C with a sensor. I checked the delivered examples from the STM32CubeL0 and can initialise the I2C. But when I send the first command, my program ends always on this line

/* Wrong size Status regarding TCR flag event */

      hi2c->ErrorCode |= HAL_I2C_ERROR_SIZE;

      HAL_I2C_ErrorCallback(hi2c);

Probably someone has any ideas...

I have attached the code

#i2c-stm32l0
1 REPLY 1
Posted on February 26, 2015 at 16:21

Regarding your source code, seems that the issue is near this function :

/**
* @brief This function handles I2C event interrupt request. 
* @param None
* @retval None
* @Note This function is redefined in ''main.h'' and related to I2C data transmission 
*/
extern ''C'' void I2Cx_IRQHandler( void )
{
HAL_NVIC_ClearPendingIRQ( I2Cx_IRQn );
if( i2cHTD.Instance->ISR & ( I2C_FLAG_BERR | I2C_FLAG_ARLO | I2C_FLAG_OVR ) )
{
HAL_I2C_ER_IRQHandler( &i2cHTD );
}
else
{
HAL_I2C_EV_IRQHandler( &i2cHTD );
}
}

Link to HAL usage and management, in comparison of StdLibrary, it is not recommended to Clear manually Interrupt, Flags or other to prevent a wrong behavior of HAL process in the driver. All treatments are done directly in the HAL driver. So to solve your issue, can you remove this line of code “HAL_NVIC_ClearPendingIRQ( I2Cx_IRQn );�? Hope that solve your issue, If it is not the case, please, can you give à snapshot of your call stack and values contains in the i2cHTD Thanks and Regards. Heisenberg.