I am interfacing nrf52840DK to a SPI module soldered by myself on a custom PCB adapter, connected by wires. This is the init code:
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG; spi_config.ss_pin = SPI_SS_PIN; spi_config.miso_pin = SPI_MISO_PIN; spi_config.mosi_pin = SPI_MOSI_PIN; spi_config.sck_pin = SPI_SCK_PIN; spi_config.mode = NRF_DRV_SPI_MODE_1; spi_config.frequency=NRF_DRV_SPI_FREQ_125K; // blocking mode APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL, NULL));
I have two issues with the default spi driver from Nordic (the one working with function nrf_drv_spi_transfer):
1. I'm using FREQ_125K but it still seems too fast (responses from slave doesn't contain expected data) and I can't find a way to decrease frequency lower than 125Kbps, given that it can only be one of these:
typedef enum
{
NRF_DRV_SPI_FREQ_125K = NRF_SPI_FREQ_125K, ///< 125 kbps.
NRF_DRV_SPI_FREQ_250K = NRF_SPI_FREQ_250K, ///< 250 kbps.
NRF_DRV_SPI_FREQ_500K = NRF_SPI_FREQ_500K, ///< 500 kbps.
NRF_DRV_SPI_FREQ_1M = NRF_SPI_FREQ_1M, ///< 1 Mbps.
NRF_DRV_SPI_FREQ_2M = NRF_SPI_FREQ_2M, ///< 2 Mbps.
NRF_DRV_SPI_FREQ_4M = NRF_SPI_FREQ_4M, ///< 4 Mbps.
NRF_DRV_SPI_FREQ_8M = NRF_SPI_FREQ_8M ///< 8 Mbps.
} nrf_drv_spi_frequency_t;
2. I can't use other GPIO pins to work as CSN,SCK,MISO and MOSI
How can I decrease speed lower than 125kbps?
How can I use other GPIO pins?
Do I need a software spi implementation?
Can you suggest a one working with nrf52?
Thank you in advance!