2024-12-25 07:37 PM
I am trying to comunicate a stm32F103C8T6 with an STM32F446 over I2C
First thing I try to do is send data as master from F103 and I get NACK by F446
Here is logic analyzer's screenshot:
And here is F446 configuration on CubeMX
I don't get why is it sending NACK when address is correct.
When trying to do the opposite (F446->F103) it sometimes throws BERR error or same thing happens, NACK with correct address
Solved! Go to Solution.
2024-12-26 07:12 PM
My issue was that slave wasn't asking available for recieving when the master tried to start a transmission
2024-12-26 12:44 AM
The address octet shown in the diagram is 00011000. There are two conventions for specifying I2C addresses. ST HAL uses the one different from your logic analyzer. For ST, the address sent (and NACKed) is 0x18. You should probably set the slave address to 0x18 in CubeMX.
2024-12-26 01:26 PM
Autogenerated code by CubeMX already takes care of it:
static void MX_I2C1_Init(void)
{
/* USER CODE BEGIN I2C1_Init 0 */
/* USER CODE END I2C1_Init 0 */
/* USER CODE BEGIN I2C1_Init 1 */
/* USER CODE END I2C1_Init 1 */
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 24;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
/* USER CODE END I2C1_Init 2 */
}
When sending the address I am also sending 0xC<<1 which is equals to 24
2024-12-26 07:12 PM
My issue was that slave wasn't asking available for recieving when the master tried to start a transmission