nrf52- SPI read/MISO with bit offset

Hi

I am using nRF52832 , SDK17, S132, reading a device ID which should be 0x67, I am reading 0x33, than 0x80 ,so it seems to be that the MISO window is getting offseted *

* as 0x67 is 1100111 and 0x33,0x80 is 110011,1000000

There is another device on the bus which I can read (its device ID) correctly, so its very weird.

what can cause this? and how can it be fixed?

Here is the SPI configuration

#define NRF_DRV_SPI_DEFAULT_CONFIG                           \
{                                                            \
    .sck_pin      = NRF_DRV_SPI_PIN_NOT_USED,                \
    .mosi_pin     = NRF_DRV_SPI_PIN_NOT_USED,                \
    .miso_pin     = NRF_DRV_SPI_PIN_NOT_USED,                \
    .ss_pin       = NRF_DRV_SPI_PIN_NOT_USED,                \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY,         \
    .orc          = 0xFF,                                    \
    .frequency    = NRF_DRV_SPI_FREQ_500K,                     \
    .mode         = NRF_DRV_SPI_MODE_0,                      \
    .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,         \
}

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
err_code = nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);

Thanks

Ron

Parents
  • Slightly confusing, settings vs 'scope image. Suggest changing the SPI Mode to 0 or 3 and see if that works as it doesn't look like Mode 0 is actually being used especially as pins are all set to NRF_DRV_SPI_PIN_NOT_USED; MISO data is maybe being sampled on the rising edge of the clock with the settings you have, and from the display it shows data should be sampled on the falling edge of the clock.

    Try
        .mode         = NRF_DRV_SPI_MODE_0,                      \
    or
        .mode         = NRF_DRV_SPI_MODE_3,                      \

Reply
  • Slightly confusing, settings vs 'scope image. Suggest changing the SPI Mode to 0 or 3 and see if that works as it doesn't look like Mode 0 is actually being used especially as pins are all set to NRF_DRV_SPI_PIN_NOT_USED; MISO data is maybe being sampled on the rising edge of the clock with the settings you have, and from the display it shows data should be sampled on the falling edge of the clock.

    Try
        .mode         = NRF_DRV_SPI_MODE_0,                      \
    or
        .mode         = NRF_DRV_SPI_MODE_3,                      \

Children
Related