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
  • Due to holidays I won't be able to get access to an logic analyzer before tuesday. Also their support telephone was already shut down. I would really like to have this problem solved asap. As I can't "waste" so much time with simple SPI. But I can't find anything I could have done wrong in the Datasheet :(

    I would like to try to have some delay before pulling ChipSelect high, gonna try to figure it out now.

    I just wrapped delay around this, as I am not 100% sure if this pulls CS high or low..

    nrf_delay_ms(10);
        nrf_gpio_pin_clear(p_spi_instance->pin_slave_select);
        spi_master_send_initial_bytes(p_spi_instance);
    nrf_delay_ms(10);
    

    But it didn't changed anything

Reply
  • Due to holidays I won't be able to get access to an logic analyzer before tuesday. Also their support telephone was already shut down. I would really like to have this problem solved asap. As I can't "waste" so much time with simple SPI. But I can't find anything I could have done wrong in the Datasheet :(

    I would like to try to have some delay before pulling ChipSelect high, gonna try to figure it out now.

    I just wrapped delay around this, as I am not 100% sure if this pulls CS high or low..

    nrf_delay_ms(10);
        nrf_gpio_pin_clear(p_spi_instance->pin_slave_select);
        spi_master_send_initial_bytes(p_spi_instance);
    nrf_delay_ms(10);
    

    But it didn't changed anything

Children
No Data
Related