cancel
Showing results for 
Search instead for 
Did you mean: 

l3g4200d an�?² stm32 problem

ocheretianko
Associate
Posted on January 05, 2012 at 22:28

Hi! I have a board with L3G4200D gyroscope and STM32F103 mcu. Gyroscope is connected to mcu via SPI bus (SPI2 on mcu). But it's not working because of some strange things. Reading from gyroscope controll registers is working normally untill i try to write something. After writing to controll registers reading of any register gives 0xFF. I can't understand what's the problem. Guys, can you help me?

Here is my code

http://pastebin.com/1NN9V0GS

http://pastebin.com/4uTHQeV4

http://pastebin.com/4vMrwUkJ

Thanks for help!
2 REPLIES 2
Posted on January 06, 2012 at 00:34

You need to be waiting on RXNE before raising the CS pin, TXE goes high as the first bit leaves the STM32, RXNE goes high as the LAST BIT LEAVES, and the last bit returned is received. Consider it as a TC (Transmit Complete) flag.

Pulling CS high early causes the slave chip to be confused, as it doesn't complete the transaction. This should be apparent if you scope the pins.

Now you will need to do a ReadData to clear the RXNE bit first, ReadData just reads the DR register
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mengsophia
Associate II
Posted on June 19, 2012 at 14:20

can i have ur entire code? cause i'm dealing with lsm330dl now ,from now on , my spi read and write are working properly, but there is something wrong with the data output, maybe we can share our code to see whether we can help each other.