This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Understanding SPIM3 Hardware CS without SDK

Hello,

could you please tell me how to configure the Hardware Chip Select Funtionality for SPIM3. I am developing a communication between a sensor and the NRF via SPI transfers over EasyDMA, where NRF is the SPI master. I want to use the PPI to start and resume SPI transfer while the CPU is asleep. This is why I am planning to go for SPIM3 with its Hardware Chip Select Function.

My question is how to set this up? So far I have had a working SPIM0 configuration and I toggled the CS pin via software. Now that I want to go for SPIM3, what else is there to be changed except from replacing the "0"s in SPIM0 by "3"s? (I tried that and saw with a logic analyzer that the CS pin was not pulled low for the SPI transfer.)

I am not working with any SDK! Otherwise I would have tried the SDK nrfx_spim example. However, I had a look at it of course to check how things were set here. I noticed the "spi_config.use_hw_ss  = true;" when setting up SPIM3. I read through the nRF Manual but could not find any register within the SPIM registers where I could set or clear the use of Hardware Chip Select. Thus, what is there to be done to set up Hardware Chip Select?

Sorry if this question is unintelligent but I am rather new to this.

Thanks.

Parents
  • Hi,

    There are tre registers that are relevant for CSN on SPIM3. The simplest way to get an overview of how this works is to refer to the SPIM chapter in the PS, and see how CSN. is configured in the nrfx driver. That essentially just call this function (copy-pasted from nrf_spim.h):

    __STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type *    p_reg,
                                                uint32_t           pin,
                                                nrf_spim_csn_pol_t polarity,
                                                uint32_t           duration)
    {
        p_reg->PSEL.CSN = pin;
        p_reg->CSNPOL = polarity;
        p_reg->IFTIMING.CSNDUR = duration;
    }

    (As a side note, I would generally advice against avoiding drivers unless you have a good reason for doing so, for a few of reasons: They will save you time, they will make your code more readable, and they often contain errata workarounds that it is easy to miss.)

Reply
  • Hi,

    There are tre registers that are relevant for CSN on SPIM3. The simplest way to get an overview of how this works is to refer to the SPIM chapter in the PS, and see how CSN. is configured in the nrfx driver. That essentially just call this function (copy-pasted from nrf_spim.h):

    __STATIC_INLINE void nrf_spim_csn_configure(NRF_SPIM_Type *    p_reg,
                                                uint32_t           pin,
                                                nrf_spim_csn_pol_t polarity,
                                                uint32_t           duration)
    {
        p_reg->PSEL.CSN = pin;
        p_reg->CSNPOL = polarity;
        p_reg->IFTIMING.CSNDUR = duration;
    }

    (As a side note, I would generally advice against avoiding drivers unless you have a good reason for doing so, for a few of reasons: They will save you time, they will make your code more readable, and they often contain errata workarounds that it is easy to miss.)

Children
No Data
Related