Mateusz Salamon

F429 HAL I2C blocks

Discussion created by Mateusz Salamon on Aug 2, 2017
Latest reply on Aug 24, 2017 by Vitaliy Chernobay

Good day!

 

I'm trying to write code for Goodix G928 touch controller with F429ZI IC. I found the I2C HAL library blocks on I2C_WaitOnFlagUntilTimeout function. The code cannot end the while loop inside function.

 

It causes in randomly moment but always after few transfers over I2C.

 

My test code looks now like below.

 

while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(LED_USR_GPIO_Port, LED_USR_Pin);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8140, 2, devID, 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8141, 2, devID[1], 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8142, 2, devID[2], 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8143, 2, devID[3], 1, 10)!= HAL_OK);

 

while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8158, 2, &x_low_byte, 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x8159, 2, &x_high_byte, 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x815A, 2, &y_low_byte, 1, 10)!= HAL_OK);
while(HAL_I2C_Mem_Read(&hi2c1, TP_ADDRESS, 0x815B, 2, &y_high_byte, 1, 10)!= HAL_OK);


while(HAL_I2C_Mem_Write(&hi2c1, TP_ADDRESS, 0x814E, 2, 0x00, 1, 10));


HAL_Delay(10);
}

 

On scrrenshot below, I2C communication stoped after 0x8158 register reading.

And few screenshots to proove randomly hanging. Same code, launched few times.

Outcomes