Skip to main content
WM_IR
Associate III
June 24, 2022
Question

I2C MASTER TRANSMIT IS NOT WORKING

  • June 24, 2022
  • 6 replies
  • 3980 views

I have tested the  

HAL_I2C_Master_Transmit(&hi2c1, 0x68, some_data, 10, HAL_MAX_DELAY);

in my nucleo stm32f302r8. But, It is not working, when I go to debug, the program retun HAL error at checking the NACK is detected or not. below is picture:

0693W00000NsjHCQAZ.jpg 

Here is my simple basic code:

0693W00000NsjHHQAZ.jpg 

Can someone help me on this problem?

This topic has been closed for replies.

6 replies

MM..1
Super User
June 25, 2022

In command

HAL_I2C_Master_Transmit(&hi2c1, 0x68, some_data, 10, HAL_MAX_DELAY);

10 mean 10 bytes and your some data have only 5. Maybe memory protection halt you.

Second mistake is HAL_MAX_DELAY, better is use real delay value for situation with bus problem.

Plus your I2C init maybe is fail, other pins etc.

WM_IR
WM_IRAuthor
Associate III
June 25, 2022

Al​

MM..1
Super User
June 25, 2022

I only write you need check if pins in CubeMX is real pins you connect to I2C on Nucleo plus on this pins pull ups external. Without this your code dont work.

And ofcourse on address 0x68 you need real function device for Acknowledge.