SPI communication using 32 bits

04 Feb 2012

I am trying to interface the mbed with a gyroscope that communicates using a 32 bit SPI interface. Can communincation be successful using the following piece of code:

cs=0;
gyroreadingu = spi.write(0xF000); //First 16 bits send and receive 16 bits 
gyroreadingl = spi.write(0x001); //Second 16 bits send and receive 16 bits
cs=1;

When I observed the clock on the oscilloscope there was a gap after the first 16 clock cycles were sent. Can this gap cause problems? From what I have read the SPI works on cyclic registers and unless data is sent no data should be received by the master. Is this correct?

Can anyone please guide me on how to use the mbed to communicate using a 32 bit interface?

04 Feb 2012

Hi,

Yes your code should work, I used similar code a while back to get 32 bit data and it worked on my device without a problem.

You can also get much closer with the hardware to set the SPI (SSP actually) port working just how you want. I wrote a notebook page on this here. This page concerns some FeRAM but I'm sure you can adapt it for your device.

Martin

05 Feb 2012

Thanks Martin! I got it working yesterday. The only problem was that you have to use a common supply for powering the MBED and the gyroscope.

Thanks again for the help.

Cheers!

Martin Smith wrote:

Hi,

Yes your code should work, I used similar code a while back to get 32 bit data and it worked on my device without a problem.

You can also get much closer with the hardware to set the SPI (SSP actually) port working just how you want. I wrote a notebook page on this here. This page concerns some FeRAM but I'm sure you can adapt it for your device.

Martin