2019-09-23 07:13 AM
Hi,
I do not understanfd why I2C init (lines 2,3) is included in While(1)? Should not it be used just one time?
1 while (1) {
2 HAL_I2C_DeInit(&hi2c1);
3 HAL_I2C_Init(&hi2c1);
4 if (_read == 1) {
5 _read = 0;
6 Console_Write("Sending commands...");
7 HAL_I2C_Master_Transmit(&hi2c1, 0x3A << 1, (uint8_t *)gpgll_msg, strlen(gpgll_msg), 2000);
8 Console_Write(" got:... \r\n");
9 for (read_buf[180-1] = 0; read_buf[180-1] != 0xff;) {
10 HAL_I2C_Master_Receive(&hi2c1, 0x3A << 1, read_buf, 180, 2000);
11 for (i = 0; i < 180; ++i)
12 if (read_buf[i] != 0xff)
13 HAL_UART_Transmit(&huart2, &read_buf[i], 1, 1000);
14 }
15 Console_Write("\r\n");
16 }
2019-09-23 07:28 AM
Hi
Lines 2 and 3 are there due to some issue on I2C.IP in some STM32.
To bypass the issue I2C-IP (in STM32) is resetted and restarted.
Hope this helps
Regards
Francesco