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

SPI read and write

Dose this capture from the Nordic Specification means that to read bytes from SPI i need to send before. Each byte i send i get a byte!!! MLy case i have read only sensor that sends periodically. If it is mandatory to send in order to receive so i have to send 4 bytes to receive the 4 bytes i am looking for.11.PNG

  • Hi,

    SPI is typically implemented using shift registers, meaning that data is clocked out of the master shift register and into the slave register through the MOSI line, and similarly, out of the slave shift register and into the master register through the MISO line.

    In theory, you should be able to clock in the data through the MISO line without having the MOSI line connected. You are still required to "send" dummy data from the master, to make the clock run.

    This operation will depend on your sensor. Could you provide details on the device? Then I might be able to help you with your setup.

    Best regards,

    Jørgen

  • Yes, this is a typical implementation - not just some strange Nordic "funny".

    This is because the SPI clock is always generated by the Master and, typically, the way to get the Master to generate its clock is to send something.

    en.wikipedia.org/.../Serial_Peripheral_Interface_Bus

  • Hi , thanks for you reaction. I am using AD7780. It is an ADC that you fixed in such frequency and do measures periodically. It works with SPI and It has 2 lines : CLK and MISO/RDY. It dose a conversion each 100ms and when the data is ready the RDY is reset. So I have to do check peiodically each 100ms is DRDY which is the same MISO if it is low and then if it is , I start reading (do SPI read) . I don't need here MOSI . I need only MISO because the AD7780 is read only peripheral. Any Idea ?
    I insist again, I don't need to send data to the AD7780 to get information back, it is sending periodically..

  • I have another question : i am using the header provided by Nordic "nrf_spim.h" and it give an API it says :

    nrf_spim_task_trigger(&stSPI_iNRF_SPI_Type,NRF_SPIM_TASK_START);
    

    So TASK start is launching an SPI transaction as in the documentation

    /**
     * @brief SPIM tasks.
     */
    typedef enum
    {
        /*lint -save -e30*/
        NRF_SPIM_TASK_START   = offsetof(NRF_SPIM_Type, TASKS_START),   ///< Start SPI transaction.
        NRF_SPIM_TASK_STOP    = offsetof(NRF_SPIM_Type, TASKS_STOP),    ///< Stop SPI transaction.
        NRF_SPIM_TASK_SUSPEND = offsetof(NRF_SPIM_Type, TASKS_SUSPEND), ///< Suspend SPI transaction.
        NRF_SPIM_TASK_RESUME  = offsetof(NRF_SPIM_Type, TASKS_RESUME)   ///< Resume SPI transaction.
        /*lint -restore*/
    } nrf_spim_task_t;
    

    When you launch a transaction dose it launch clk ???

  • when the data is ready the RDY is reset. So I have to do check peiodically each 100ms

    No, you don't have to: that is one approach - but not the only approach.

    An alternative would be to use an interrupt ...

Related