This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI interfacing with gyroscope (part 2)



Hi guys,

http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/323982/1134705.aspx#1134705

This is a continuation of the topic in the link above.

Even thought i was able to receive data from the WHO_AM_I register, when tried to read CTRL_REG1 register, it gives the wrong value. I also tried to do a write and read but the value was not what i expected. i suspect there are still setting i did not get it correct. things i tried were to reduce the baudrate and tried some of the data format setting

The expected print out should be 211,7,0,0,0,0,211,15,0,8,32,0. but i got  211 ,15 ,0 ,0 ,0 ,0 ,255 ,255 ,15 ,0 ,0 ,0.

i also attached the project file for your viewing.

5140.workspace_robot.zip

Thank you all for the help given soo far. 

Regards,

Yuanfa

  • Yuanfa,

    It appears that the clock polarity that you're using on the RM42 doesn't match what's in the gyroscope datasheet.  At least in the gyro datasheet I see that data is valid on the rising edge of SPICLK.  But I took a couple shots of your program and it appears to be valid on the falling edge and changing on the rising edge.

    Yellow is clock.  Blue is SIMO, Purple is CS\.  You can see better on the zoom in.

    Zoom in:

    To fix this you need to match the clock polarity / phase of the TMS570 SPI master with what the GYRO is looking for.

    I didn't check your 2nd transmission - this is the WHOAMI.  But the code for your write looked ok.

    Probably your WHOAMI read works ok because the code is an 'F' and there's not really toggling of data bits...

    If you have trouble w. your CTRLREG1 read. please take a shot like this.

  • Hi Anthony and everyone,

    I manage to solve the problem. I check the oscilloscope and realize the clock polarity is different  from the recommended from datasheet. I change it but the problem remains. The signal however  was already correct. Therefore I realize the data read was reading the old values from the spi write. To flush the value away, I used spiSendAndGetData instead of spiSendData and the problem was solved. I also retrieved the gyroscope value and it seems to be what I expected.

    I am just curious Anthony, your signal data image you attached, its a software/emulated oscilloscope or you used an actual oscilloscope and retrieve the image out.

    Thank you everyone for the help from start to end.

    Regards,

    Yuan Fa.