2016-08-17 02:35 AM
Hello,
when I read a single Byte from I2C using the HAL_I2C_Mem_Read_IT function, all following read or write attempts on the same I2C bus fail with HAL_Timeout.
When I run exactly the same code on a STM32F2 (using the F2 HAL Drivers) I have no Problems.
Do you have any idea what could cause this issue?
2016-08-17 05:09 AM
Hi Oli,
Could you please precise the firmware versions of both STM32Cube Packages that you are using for F2 and F4?-Mayla-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.
2016-08-17 07:53 AM
Hi Oli,
I have the same problem. I am using -STM32CubeF4 Firmware Package V1.0 /01-July-2016 -STM32CubeMX 4.16 The first Interrupt-Callback function will be triggered. So you can generate the Stop manually. This works for me.void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {
/* Generate Stop */
hi2c->Instance->CR1 |= I2C_CR1_STOP;
hi2c->State = HAL_I2C_STATE_READY;
}
Best Regards
Kevin
2016-08-19 05:05 AM
Hi Kevin,
thank youthat seems to work great.
I'm using Firmware package 1.0.
BTW:
I found a difference between F2 and F4 HAL Drivers:
In function
static
HAL_StatusTypeDef I2C_Master_ADDR(I2C_HandleTypeDef *hi2c)
The F2 Driver has the following code:
else if(hi2c->XferCount == 1U)
{
if(CurrentXferOptions == I2C_NO_OPTION_FRAME)
{
/* Disable Acknowledge */
hi2c->Instance->CR1 &= ~I2C_CR1_ACK;
if((hi2c->Instance->CR2 & I2C_CR2_DMAEN) == I2C_CR2_DMAEN)
{
/* Disable Acknowledge */
hi2c->Instance->CR1 &= ~I2C_CR1_ACK;
/* Clear ADDR flag */
__HAL_I2C_CLEAR_ADDRFLAG(hi2c);
}
else
{
/* Clear ADDR flag */
__HAL_I2C_CLEAR_ADDRFLAG(hi2c);
/* Generate Stop */
hi2c->Instance->CR1 |= I2C_CR1_STOP;
}
}
The F4 Driver does not have These instructions. As far as I understand this, this code generates a STOP on the I2C bus wenn the last Byte was read. This would be a reason why it works with F2 Drivers but not with F4 Drivers.
2016-08-24 04:07 AM
Hi Oli,
Thanks for highlighting this issue. I will check it with our development team & come back to you. Sorry for the inconvenience it may bring.-Syrine-