Report
3 months, 1 week ago.

SPI read value stuck on 0 with nucleo L476RG on MBed

The title says it all. I'm stuck with an issue, where all signals are correct on oscillscop, I should be reading the 0x49FC value, but all I get is 0x0000. I'm using MBED, and still cannot read anything else but zero.

Here's an extract of the code I'm using:

/////////////

  1. include "mbed.h"

SPI spiPressure(PC_12,PC_11,PC_10);

spiPressure.format(16,1);

spiPressure.frequency(100000);

spiPressure.lock();

int d1;

d1 = 0;

spiPressure.write(0x0015);

spiPressure.write(0x5540);

while (d1==0)

{

spiPressure.write(W1_CMD);

d1 = spiPressure.write(0);

wait(0.1);

}

printf("!!!! Init OK %d",d1);

//////////////

I tried all the 4 modes, despite the fact that mode 1 seems to be the correct one accordingly to the datasheet of the adressed CI, I tried with and without the lock() feature (there's only one device on that SPI port).

As seen below, the conncected SPI slave is responding correctly, but so far d1 is set to 0.

What am I missing ?

/media/uploads/cthalatoo/pb_spi.png

Comment on this question

1 Answer

1 week, 3 days ago.

Hello Christophe, What kind of SPI sensor are you using? Can you attach the datasheet for the SPI sensor? Can you also explain what does this part of the code do?

spiPressure.write(0x0015); spiPressure.write(0x5540);

and this line: spiPressure.write(W1_CMD);

Thank you, Peter, Mbed Team


To post an answer, please log in.