I need help with this piece of code. I don't know what I did wrong, or what I'm missing. It is a simple program to interface the stm32f103c8t6 with a gy-521 (the MPU6050 on it), I was able to get it working when I used the ESP8266 and arduino, but now I'm using keil uvision with the STM and I don't know why it's not working.
Here is the full code: http://codepad.org/fMh3m2JC
These are the libraries I used
I set up a debugging process to monitor what the problem is and I discovered that it gets stuck in the while loop on line 123, everything works fine up to this point.
The while loop lets the MCU waits for the I2C_EVENT_MASTER_BYTE_RECEIVED event, this event is simply a mask for the BUSY, MSL and RXNE flags.
I monitored the i2c interface window as I stepped through the code then I realised that the MSL and RXNE were not set at this point which means the MCU is in slave mode and the data register is still empty, the ARLO bit is set which I think it shouldn't be at this point.
Anyway, all these are just my hypothesis based on my limited knowledge and experience. The problem may not be related to these things, I just want someone to take a look at the code and tell me what I'm doing wrong. Thanks.
PS: I also notice that the onboard LED refuses to flash, is it because of the i2c communication?