Skip to main content
Explorer
October 22, 2024
Solved

I2C in STM32MP13xx giving continuously NACK after start condition with STPMIC1 in bare-metal environment

  • October 22, 2024
  • 2 replies
  • 2214 views

Hi,

I am working on STM32MP133FAFx (I2C Master) for I2C communication with STPMIC1 IC (I2C slave) fast mode(400KHz) and HSI clock(64MHz). I2C->TIMINGR = 0x00C0216C

I am trying polling method in bare-metal environment for communication in I2C.

Below is my algorithm for polling

1. Configure HSI clock and Initialize clock for I2C.

2. Configuring GPIO I2C pins (No pull up, no pull down, I2C AF, Medium speed)

3. Disable I2C before configuration with I2C_CR1_PE

4.  Setting I2C->TIMINGR = 0x00C0216C for 400KHz baud

5. Setting 7-bit addressing, enable clock Stretching, clear general call & enable filters

6. Enable I2C and shift slave address by 1 as its 7 bit (SlaveAddress << 1)

7. Setting I2C in I2C_AUTOEND_MODE mode

8. After calling I2C_TransferConfig() function I am getting NACK bit is getting set as in attached picture

 

Please help me how to resolve this issue and provide me the solution.

 

 

 

  

 

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

    Hi @sandeepBJadhav 

    did you try configuring GPIO in OD ?

    did you see the ACK on the bus ?

    did you use 0x33 as address (before shift) ?

    Regards.

    2 replies

    Explorer
    October 22, 2024

    Hi,

    I am working on STM32MP133FAFx (I2C Master) for I2C communication with STPMIC1 IC (I2C slave) fast mode(400KHz) and HSI clock(64MHz). I2C->TIMINGR = 0x00C0216C

    I am trying polling method for communication in I2C.

    Below is my algorithm for polling

    1. Configure HSI clock and Initialize clock for I2C.

    2. Configuring GPIO I2C pins (No pull up, no pull down, I2C AF, Medium speed)

    3. Disable I2C before configuration with I2C_CR1_PE

    4. Setting I2C->TIMINGR = 0x00C0216C for 400KHz baud

    5. Setting 7-bit addressing, enable clock Stretching, clear general call & enable filters

    6. Enable I2C and shift slave address by 1 as its 7 bit (SlaveAddress << 1)

    7. Setting I2C in I2C_AUTOEND_MODE mode

    8. After calling I2C_TransferConfig() function I am getting NACK bit is getting set as in attached picture

     

    Please help me how to resolve this issue and provide me the solution.

    PatrickFAnswer
    Technical Moderator
    October 25, 2024

    Hi @sandeepBJadhav 

    did you try configuring GPIO in OD ?

    did you see the ACK on the bus ?

    did you use 0x33 as address (before shift) ?

    Regards.

    Explorer
    October 25, 2024

    Thanks for response.

    Actually I am not setting pins as open-drain that was the problem.

    After setting OD I am getting ACK properly

    ST Employee
    October 24, 2024

    Hello @sandeepBJadhav 

    This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

    Regards,

    Roger