I have initialized SPI0 master by this code:
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(0);
...
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = SPIM0_SS_PIN;
spi_config.miso_pin = SPIM0_MISO_PIN;
spi_config.mosi_pin = SPIM0_MOSI_PIN;
spi_config.sck_pin = SPIM0_SCK_PIN;
spi_config.mode = NRF_DRV_SPI_MODE_1;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL));
Then I try to send some data via SPI:
uint8_t tx_buf[] = { 0x11 };
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, tx_buf, sizeof(tx_buf), NULL, 0));
But my application hangs inside spi_xfer (in nrf_drv_spi.c) at this line:
while (!nrf_spi_event_check(p_spi, NRF_SPI_EVENT_READY)) {}
The strangest thing for me is sometimes my application works fine, but it rarely happens (the firmware can not be changed - the application can earn or vice versa start hanging after a few reboots).
What could be the problem?