2022-06-24 04:28 PM
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:
Here is my simple basic code:
Can someone help me on this problem?
2022-06-24 08:33 PM
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.
2022-06-24 11:02 PM
Al
2022-06-24 11:03 PM
Already changed to 5 bytes..and the time i just put 10. Is it ok? But still not working. And about the i2c init pin, im using the cubemx where it automatically generate the code. I dont see the initialization is the problem.
2022-06-25 12:37 AM
CubeMX set I2C pins on selection I2C to default pins, but exist alternate positions and Nucleo boards dont use alltime defaults.
2022-06-25 12:48 AM
Then, how should i configure the pin?
2022-06-25 01:13 AM
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.