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

SPI AND SPIM READING ISSUES

hi all i am trying to read data from a sensor in burst mode i can"t able to read all datas from the register .I tried to read the data in both spi and spim(with easydma) . spim is more better it reads data from 2 register(i am trying to read data of 3 register using burst mode).how can i solve this issues.

Parents
  • I assume you control NCS correctly, setting low before the first of two transfers and only high after the second with the 4 uSec delay between the two transfers. However your code shows that you are also telling the nRF SPI code to take control of NCS. Here is the default setting for NCS and the handler for init:

    // Starts by assuming NCS is not required
    
    /**
     * @brief SPI master instance default 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_4M,                     \
        .mode         = NRF_DRV_SPI_MODE_0,                      \
        .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,         \
    }
    
    // Tests if NCS is not required
    
        // - Slave Select (optional) - output with initial value 1 (inactive).
        if (p_config->ss_pin != NRF_DRV_SPI_PIN_NOT_USED)
        {
            nrf_gpio_pin_set(p_config->ss_pin);
            nrf_gpio_cfg_output(p_config->ss_pin);
        }
        m_cb[p_instance->drv_inst_idx].ss_pin = p_config->ss_pin;
    
    

    However your code shows that you are requesting the nRF SPI driver to take over NCS:

    spi_config.ss_pin = SPI_MOUSE_CSN_PIN;

    The nRF handler will now drive NCS low before and high after every transaction, including between the two transactions you require, for example sww nrf_drv_spi.c

    static void finish_transfer(spi_control_block_t * p_cb)
    {
        // If Slave Select signal is used, this is the time to deactivate it.
        if (p_cb->ss_pin != NRF_DRV_SPI_PIN_NOT_USED)
        {
            nrf_gpio_pin_set(p_cb->ss_pin);
        }
    
    

  • so i want to remove this  "spi_config.ss_pin = SPI_MOUSE_CSN_PIN;" portion from the code  then only i get correct data from burst mode read.

Reply Children
No Data
Related