This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI_Master : Expecting same result in SPI Mode 0 and 3 but it differs

In the sensor datasheet it says one can use SPI_Mode 0 or 3 (doesn't say that there is anything to do to switch between them).

I connected MISO from the DK with SDO from the Sensor and MOSI with SDI

image description

I tried all 4 CPHA/CPOL combinations and 2 should give me the same result.. but they all differ! (Of course I chose a coefficient that should be constant (and with no change in spi mode but just resetting to get the result again it is.).

RX from left to right: reset-command, prom-read-command 0xA6, prom read results

ActiveLow + Trailing : FE FE 92 93 
ActiveLow + Leading : FF FF C9 49 
ActiveHigh + Leading : FE FE FE C8 
ActiveHigh + Trailing : FF FE FE 87

What am I missing? I used the ble_uart example and added SPI. Of course I tried other speeds too.

Maybe someone with a 100% working SPI Slave could flash, just edit the command and test if the code works?

main.c ble_app_uart.zip

Datasheet of Sensor

Parents
  • Of course I made a list of possible combinations from everything I could imagine... spi modes, speeds, commands, sending 1/2/3 bytes at once.. and nothing seemed to work.

    But I just tried it again now with 3bytes at once (prom read command + 2byte read) and this time I got the same results!!! I really don't know what my sleepy mind missed yesterday evening but I will forgive him if it finally works now! ActiveLow+Trailing or High+Leading. Gonna test it some more now..

    Seem to work so far.

    Conclusion: This sensor ( MS5803 ) is not as cool with getting deselected in between reading command and the reading itself as i thought...

    This sentence of the datasheet had me confused:

    The CSB pin can be pulled high after the command is sent or after the end of the command execution (for example end of conversion)

    I am still wondering if the reset command in the beginning actually works if I pull CSB high and then wait 3ms and not the other way around.

  • Thank you very much for these kind words. Reciprocity is key. Even though I'm afraid the next few weeks I will be mostly taking. (I already have the feeling I would flood the devzone with questions... But I have little to no choice as I got a hard deadline (and many side aspects.. hardware layouting e.g.) and I'm not well grounded with these topics yet). The beginning is always the hardest part.. new development environment, new µC architecture + BLE. But the time I'll answer foreign questions will come!

Reply
  • Thank you very much for these kind words. Reciprocity is key. Even though I'm afraid the next few weeks I will be mostly taking. (I already have the feeling I would flood the devzone with questions... But I have little to no choice as I got a hard deadline (and many side aspects.. hardware layouting e.g.) and I'm not well grounded with these topics yet). The beginning is always the hardest part.. new development environment, new µC architecture + BLE. But the time I'll answer foreign questions will come!

Children
No Data
Related