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 the sdk version is nRF5_SDK_14.2.0_17b948a .

    uint32_t adns_motion_burst_read(const nrf_drv_spi_t * i_spi_address , uint8_t * motion , uint8_t * deltaY , uint8_t * deltaX)
    {

    uint32_t err_code;

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

    uint8_t tx_bm_data;
    uint8_t rx_bm_dummy; //receive buffer for dummy
    uint8_t i_reg;

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


    i_reg = ADNS_REG_MOTION_BURST;
    // Format for register in burstmode read
    tx_bm_data = i_reg & 0x7f; // The MSB to "0" to indicate a read operation

    // Write to Motion_Burst register.
    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,(const uint8_t *)&tx_bm_data,1,&rx_bm_dummy,1));
    *motion = rx_bm_dummy; // Execute dummy read to clear RX buffer for motion

    nrf_delay_us(4); //tSRAD

    // Write out a dummy data byte which will be ignored and read motion data
    // APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,NULL,0,&rx_bm_data[0],3));

    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,NULL,0,&rx_bm_data[0],1));
    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,NULL,0,&rx_bm_data[1],1));
    APP_ERROR_CHECK(nrf_drv_spi_transfer(i_spi_address,NULL,0,&rx_bm_data[2],1));

    adns_ncs_assert(i_spi_address,1); //disable ncs


    *motion = rx_bm_data[0];
    *deltaY = rx_bm_data[1];
    *deltaX = rx_bm_data[2];

    nrf_delay_us(4); //tBEXIT

    return NRF_SUCCESS;
    }

    i am trying to read 3 bytes of data from a register  in ADNS3530 motion sensor . only the first byte data is getting correctly other two bytes of data is getting but not getting continuously .

    burst mode means: - Burst mode is a special serial port operation mode that may be used to reduce the serial transaction time for a motion read. The speed improvement is achieved by continuous data clocking from multiple registers without the need to specify the register address, and by not requiring the normal delay period between data bytes.Burst mode is activated by reading the Motion_Burst register. The ADNS-3530 will respond with the contents of the Motion, Delta_Y, Delta_X, SQUAL, Shutter_Upper, Shutter_Lower and Maximum_Pixel registers in that order. The burst transaction can be terminated after the first three bytes of the sequence are read by bringing the NCS pin high. After sending the register address, the microcontroller must wait tSRAD and then begin reading data. All data bits can be read with no delay between bytes by driving SCLK at the normal rate. The data is latched into the output buffer after the last address bit is received. After the burst transmission is complete, the microcontroller must raise the NCS line for at least tBEXIT to terminate burst mode. The serial port is not available for use until it is reset with NCS, even for a second burst transmission.

  • sir i answered to your question i didn"t got any replys 

Related