cancel
Showing results for 
Search instead for 
Did you mean: 

I2C not working with MPU6050

sivansriman
Associate

Hello

I've been trying to shift over to STM32CubeIDE from the Arduino IDE and I have written the code for MPU6050 in CubeIDE using the HAL Libraries. However when I Debug the code and observe the values, its clear that the connection isnt established properly. To verify that nothing is wrong with my board, I used my old code in the arduino ide and it works there. Can someone help me with this? I am using stm32f401ccu6 blackpill with stlink v2. I am able to run simple blink codes in CubeIDE with this setup, but the I2C interfacing is not working. Any help would be appreciated. I have attached my code here as well for others to verify. Please let me know if there might be any configuration I might be missing out in the ioc file.

Thanks,
Sivan Sriman

1 ACCEPTED SOLUTION

Accepted Solutions
sivansriman
Associate

Ok I dont know whether to laugh or cry, but I guess the problem was i was still using the same 0x68 (7bit address )as the address where I shouldve used 0xd0 (8bit address). My declaration of the address should have been
#define MPU_ADDR 0x68 << 1 instead of just 0x68 

View solution in original post

1 REPLY 1
sivansriman
Associate

Ok I dont know whether to laugh or cry, but I guess the problem was i was still using the same 0x68 (7bit address )as the address where I shouldve used 0xd0 (8bit address). My declaration of the address should have been
#define MPU_ADDR 0x68 << 1 instead of just 0x68