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 Reply Children
  • SIR WHEN I USED SPI (NOT SPIM "SPI0_USE_EASY_DMA 0 "IN  sdk_config.h) AND NORMAL READ OPERATION THE VALUES FROM ALL THREE REGISTER GETTING PROPERLY.I WILL PLACE THE CODE FOR NORMAL READ BELOW

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

    uint32_t adns_reg_read(const nrf_drv_spi_t * i_spi_address,uint8_t i_reg, uint8_t *io_data)
    {
    uint32_t err_code;

    /* Read operation. See ADNS-3530 datasheet (p.12).

    A read operation, defined as data going from the ADNS-3530 Sensor to the
    micro-controller, is always initiated by the micro-controller and consists
    of two bytes. The first byte contains the address, is sent by the micro-controller
    over MOSI, and has a "0" as its MSB to indicate data direction. The second byte
    contains the data and is driven by the ADNS-3530 Sensor over MISO. The sensor outputs
    MISO bits on falling edges of SCLK and samples MOSI bits on every rising edge of SCLK.

    */
    uint8_t tx_data[2];
    uint8_t rx_data[2];

    // Reset serial port
    adns_ncs_assert(i_spi_address,1); //disable ncs
    adns_ncs_assert(i_spi_address,0); //enable ncs

    if(i_spi_address == NULL | io_data == NULL)
    {
    return NRF_ERROR_INVALID_PARAM;
    }

    // The MSB to "0" to indicate a read operation
    tx_data[0]= i_reg & 0x7f;
    tx_data[1]= 0xff; // Buffer to provide clock for rx data.

    // Send the address to read
    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,(const uint8_t *)&tx_data[0],1,&rx_data[0],1));

    nrf_delay_us(4); // tSRAD delay

    // Read the data by sending a dummy byte
    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,(const uint8_t *)&tx_data[1],1,&rx_data[1],1));

    adns_ncs_assert(i_spi_address,1); //disable ncs

    // Return the second byte from rx_data
    *io_data = rx_data[1];


    return NRF_SUCCESS;
    }

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

  • BUT I WANT READ THE DATA IN BURST MODE . THEN ONLY THE DEVICE WORK PROPERLY.

  • SIR PLEASE REPLY

    WHY WE CAN'T READ MORE THAN I BYTE USEING  

    "nrf_drv_spi_transfer(i_spi_address,NULL,0,&rx_bm_data[0],3)" THIS FUNCTION

    BY THIS CONFIGURATION

    spi_config.ss_pin = SPI_MOUSE_CSN_PIN; 

    THE WRITE OPERATION OF MORE THEN 2 BYTE IS GETTING PROPERLY WITH THIS FUNCTION

    "nrf_drv_spi_transfer(i_spi_address,(const uint8_t *)&tx_data[0],2,&rx_data[0],2)"

    BY THIS CONFIGURATION

    spi_config.ss_pin = SPI_MOUSE_CSN_PIN; 

Related