Please help with writing to flash. If SoftDevice is off all ok. If SoftDevice is enabled, the sd_evt_get function always returns the value 5.
Here is the test code:
void FlashTestWrite(uint8_t TestData[4])
{
if(nrfx_nvmc_flash_page_size_get() != 0x1000)
return;
if(nrf_sdh_is_enabled())
{
uint32_t p_event;
ret_code_t err_code;
bool flash_busy = true;
err_code = sd_flash_page_erase((0x27000 / 0x1000));
APP_ERROR_CHECK(err_code);
while(flash_busy)
{
err_code = sd_evt_get(&p_event);
if(err_code == NRF_SUCCESS)
{
if(p_event == NRF_EVT_FLASH_OPERATION_SUCCESS)
flash_busy = false;
if(p_event == NRF_EVT_FLASH_OPERATION_ERROR)
return;
}
}
uint32_t test_data[1];
test_data[0] = (uint32_t)(TestData[3] << 24) + (uint32_t)(TestData[2] << 16) + (uint32_t)(TestData[1] << 8) + (uint32_t)TestData[0];
flash_busy = true;
err_code = sd_flash_write((uint32_t*)0x27000, test_data, 1);
APP_ERROR_CHECK(err_code);
while(flash_busy)
{
err_code = sd_evt_get(&p_event);
if(err_code == NRF_SUCCESS)
{
if(p_event == NRF_EVT_FLASH_OPERATION_SUCCESS)
flash_busy = false;
if(p_event == NRF_EVT_FLASH_OPERATION_ERROR)
return;
}
}
}
else
{
nrfx_nvmc_page_erase(0x27000);
nrfx_nvmc_bytes_write(0x27000, TestData, 4);
do
{
nrf_delay_ms(1);
}while(nrfx_nvmc_write_done_check() != true);
}
}