Hello,
we are developing a firmware for the nRF52840 which requires the use of Bluetooth and the SPIS (SPI Slave) functionality.
We are using S140 & SDK 16.
We encounter the following problem:
During init, we configure a 2 byte TX buffer for SPIS.
After init, the master initiates a 2 byte transaction.
With a logic analyzer we can observe that the nRF is correctly clocking out the 2 byte long buffer on MISO.
But for every successive transaction, the nRF is clocking out the default byte (as defined in register DEF).
The SPIS event handler is an empty function, so it should not reconfigure anything.
We traced the problem to the function nrf_pwr_mgmt_run(void)
void nrf_pwr_mgmt_run(void) { PWR_MGMT_FPU_SLEEP_PREPARE(); PWR_MGMT_SLEEP_LOCK_ACQUIRE(); PWR_MGMT_CPU_USAGE_MONITOR_SECTION_ENTER(); PWR_MGMT_DEBUG_PIN_SET(); // Wait for an event. #ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { ret_code_t ret_code = sd_app_evt_wait(); ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)); UNUSED_VARIABLE(ret_code); } else #endif // SOFTDEVICE_PRESENT { // Wait for an event. __WFE(); // Clear the internal event register. __SEV(); __WFE(); } PWR_MGMT_DEBUG_PIN_CLEAR(); PWR_MGMT_CPU_USAGE_MONITOR_SECTION_EXIT(); PWR_MGMT_SLEEP_LOCK_RELEASE(); }
The SPIS works for successive transactions when we either
1. Don't call the nrf_power_mgmt_run(void) function
2. Comment out the lines 'PWR_MGMT_FPU_SLEEP_PREPARE();' and 'ret_code_t ret_code = sd_app_evt_wait();'
We therefore suspect that the call to sd_app_evt_wait() is the culprit.
Additionally, if we replace the call to nrf_power_mgmt_run(void) to a call to __WFE() the SPIS is also still working.
Is the SPIS not compatible with the BLE stack? Are we missing something else?
We would greatly appreciate any input on this problem.