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

Change Polarity of Chip Select line for SPI devices

Hi,

I would like to know the correct way to change the polarity of the CS line for SPI devices. The SHARP memory display is opposite of most SPI slave devices so I need to use the CSNPOL register so the SPI subsystem can correctly handle the line.  I have the Sharp display and an RTC on the same bus, each one requiring different polarity for its operation.

Currently I am using SDK 15.2 with the SPI manager, and am following the SPI manager example from the SDK. I would prefer it to be a part of the SPI configuration structure so I can use multiple configurations.

Any insight would be appreciated.

Thank you and happy new year!

-Ben

Parents
  • Take a look into nrfx_spim.c, you will see that the 'ss' pin (slave select) can be programmed to be active high or low. This is part of the struct spim_control_block_t declared line 116.

    To set this polarity, assuming that you are setting the 'ss' pin and using it as an integrated part of driver (it sounds like you are) then when you call the nrfx_spim_init() function with the nrfx_spim_config_t stuct you need to be setting the configuration fields as:

    nrfx_spim_config_t spim_config = {

    ...

        .ss_pin = (the pin you are using - keep this the same),

        .ss_active_high = true,

    ...

    };

    I think that should do it.

    Note to Nordic: A very nice job on the SPIM and SPIS hardware. It is very well thought out, easy to use, and DMA everywhere. This is how life should be.

Reply
  • Take a look into nrfx_spim.c, you will see that the 'ss' pin (slave select) can be programmed to be active high or low. This is part of the struct spim_control_block_t declared line 116.

    To set this polarity, assuming that you are setting the 'ss' pin and using it as an integrated part of driver (it sounds like you are) then when you call the nrfx_spim_init() function with the nrfx_spim_config_t stuct you need to be setting the configuration fields as:

    nrfx_spim_config_t spim_config = {

    ...

        .ss_pin = (the pin you are using - keep this the same),

        .ss_active_high = true,

    ...

    };

    I think that should do it.

    Note to Nordic: A very nice job on the SPIM and SPIS hardware. It is very well thought out, easy to use, and DMA everywhere. This is how life should be.

Children
Related