2014-11-04 08:13 AM
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-stm32l02015-02-26 07:21 AM
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.