cancel
Showing results for 
Search instead for 
Did you mean: 

i2c slave not printing the received data

Rohit007
Associate II

hii, 

i am using stm32 nucleo g0-b1re i am trying to receive data in interrupt mode, but cant figure out what is wrong, i am new to stm32 i2c protocol.

i have used master as nucleo-h743zi2 and transmitting data, but it is not showing anything on minicom.

 

6 REPLIES 6
Pierre_Paris
ST Employee

Hello @Rohit007,

Try this code :

 

   /* USER CODE BEGIN 2 */
  /*##- Put I2C peripheral in reception process ###########################*/
  if (HAL_I2C_Slave_Receive_IT(&hi2c1, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
  {
    /* Transfer error in reception process */
    Error_Handler();
  }

  /*##- Wait for the end of the transfer ###################################*/
  /*  Before starting a new communication transfer, you need to check the current
      state of the peripheral; if it�s busy you need to wait for the end of current
      transfer before starting a new one.
      For simplicity reasons, this example is just waiting till the end of the
      transfer, but application may perform other tasks while transfer operation
      is ongoing. */
  while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY)
  {
  }
   /* USER CODE END 2 */

 

 Best Regards,

Pierre

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

actually it is not receiving a single bit of data, it is not entering into address callback function.

 

Pierre_Paris
ST Employee

Are you aware of this article? It explains what is I2C is and how to use it through examples.

I advise you to read it if you are new to stm32 I2C protocol. 🙂

What is your application ? Who is the master ?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

my application is to read variable amount of data sent by the master. my master is nucleo- h743zi2 it is sending data of variable amount, i.e. if i send 5 byte my slave should read only that much data or if 10 bytes, slave should be ready to read that too.

 

TDK
Guru

Use a logic analyzer to understand what is happening on the line.

If you feel a post has answered your question, please click "Accept as Solution".
Pierre_Paris
ST Employee

Hello @Rohit007,

Here are some remark about what may happen :

  • Are you sure you are sending the data ? to the right address ? 
  • Have you scoped SDA and SCL ? I advise you to do it
  • Are the HAL functions (Transmit or Receive) return an error or success code ?
  • Can you share more information about your code (config h743zi2  also) and the hardware settings maybe ?

Best Regards,

Pierre

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.