Skip to main content
Explorer
December 26, 2024
Solved

STM32F446 NACK on correct address

  • December 26, 2024
  • 3 replies
  • 726 views

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:

Dioswilson_0-1735183975794.png

And here is F446 configuration on CubeMX

Dioswilson_1-1735184006625.png

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

    This topic has been closed for replies.
    Best answer by Dioswilson

    My issue was that slave wasn't asking available for recieving when the master tried to start a transmission

    3 replies

    Graduate
    December 26, 2024

    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.

    Explorer
    December 26, 2024

    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 

    DioswilsonAuthorAnswer
    Explorer
    December 27, 2024

    My issue was that slave wasn't asking available for recieving when the master tried to start a transmission