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

gpio not set or clear with spi code

I need to communicate with a sensor through SPI. However, in order for the sensor to switch to SPI mode, its CS pin must go down. So before I do SPI transfer, I clear that CS pin; and set it again after transfer is done.

// init function
nrf_gpio_cfg_output(SPI_SS_PIN);


// SPI function
nrf_gpio_pin_clear(SPI_SS_PIN);

// Start transfer.
uint32_t err_code = nrf_drv_spi_transfer(&m_spi_master,
    m_tx_data, 1, m_rx_data, 1);

// set CS pin for next SPI communication
nrf_gpio_pin_set(SPI_SS_PIN);

However, when I use scope to monitor the SPI_SS_PIN, I don't see it going from 1 to 0 and cominb back.

I am using nRF52 evaluation board with SDK12 without SoftDevice. The pin assignments are as

	.sck_pin  = SPI_SCK_PIN,             //  7
	.mosi_pin = SPI_MOSI_PIN,            //  13
	.miso_pin = SPI_MISO_PIN,            //  15
	.ss_pin   = SPI_SS_PIN,              //  14

When I use those 3 gpio functions in another simple program without SPI calls, I can see the value change of that PIN.

What do I do wrongly?

Related