I’m working on getting a STM32F405RG communicating with a L3GD20 Gyroscope via I2C. I’m having issues getting real data back from the gyro.
I am a 33 yr old junior in Electrical Engineering at ULL. This is not a school project as the projects for school are much more mundane and simple, I could only wish we’d do something like this in school. I’ve worked professionally with electricity in some form or another since I was 17, first as an electrician, 6 years Air Force as an avionics tech, 6 years in the oilfield working with computer automation and instrumentation. I’ve always played around with software as a hobby and have taken enough classes to have a minor in computer science upon graduation. I’d classify myself as an intermediate to advanced hobbyist using C#, java and assembly. This is my first round with plain C.
Hardware-wise, I’m fairly experienced working with analog circuitry, PLC’s and high-level language uC’s like the Netduino , parallax and picaxe offerings.
The board I’m using is actually a Netduino Plus 2 where Ive erased the chip with STDefuse. I’m using Atollic Truestudio along with the STLink V2 debugger for debugging. The L3GD20 is a breakout board (MinIMU_V2) from Polulu containing the L3GD20 gyroscope along with a LSM303DLHC accelerometer/magnetometer. I believe my pull-ups were in the neighborhood 0f 2000 ohms which I came to by using my o-scope to get as close to or beneath 200 nS rise time for 100kHz I2C. I got it to about 200 nS and I2C was quite sturdy with this setup. I was using the Netduino as it was with .NETMF and C# along with the MinIMU_V2 and two other I2c boards with no problems, so I’m positive the hardware is functional.
The Current Setup:
Currently, I’m using the erased Netduino Plus 2 with the MinImu_V2 connected to it via PB6 and PB7. These were the same pins being used by the netduino framework for I2C. I’ve removed the other I2C devices to simplify for troubleshooting. I’m still using the same pull-ups and have verified my rise time is still good, I’m at about 195 nS.
I’ve written a program to read the out values from the L3GD20 using I2C. I adapted the L3G4200D platform-independent driver from ST for use with the L3GD20. Only real difference is ranges, register names and memory locations. I’m also using the stm32f4xx_i2c.h file from the Standard Peripherals Library Ver 1.1.0. The program compiles and debugs fine, I just don’t seem to get any real data back from the L3GD20. When I step through the project, any reads I make result in getting 0xD7 back. 0xD7 happens to be the 7-bit slave address of the L3GD20 (0x6B with SDO tied high) ORed with 0x01 after attaching the LSB for read.
I’m thinking my problem is in the sequencing of my I2C read and write. I’m not worried about multiple reads right now, I should be able to figure that out once I get single byte reads and writes straight. I’ve found small differences in the ‘guidelines’ sited in the STM32F4xx Reference Manual, the L3GD20 datasheet and the commented instructions inside the stm32f4xx_i2c.h file as far as sequence goes.
Here is some of my code:Main:
When watching valueL and valueH in the L3GD20_GetAngRateRaw function during debugging, all i ever get back is 0xD7.
Of course there is more to the last file, but it would be a lot to post. I just wanna make sure my read and write sequences are correct then I can move on to any other issues that could be in there.
Anyone see any issues here?