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

Not getting NRF_EVT_FLASH_OPERATION_SUCCESS

Hi all, After receiving data from my host app, I am trying to write to write the data to flash with the sd_flash_write command. I have 3 pages of data to write, so need to make sure the last write has finished by waiting for NRF_EVT_FLASH_OPERATION_SUCCESS. I do not receive this however while the ble is running. I placed the sd_evt_get in the interrupt handler:

void SWI2_IRQHandler(void)
{
	uint error;
	uint event;
	word length;
	bool softEvent = true;
	bool bleEvent = true;
	
	while (1)
	{
		if (softEvent)
		{
			error = sd_evt_get(&event);
			if (error == NRF_ERROR_NOT_FOUND)
				softEvent = false;
			else if (error != NRF_SUCCESS)
			{
				// Error
			}
			else
			{
				BluetoothSystemEventHandler(event); // Doesn't get called	

			}
		}
		if (bleEvent)
		{
			length = bleBufferSize;
			error = sd_ble_evt_get(bleEventBufferOffset, &length);
			if (error == NRF_ERROR_NOT_FOUND)
				bleEvent = false;
			else if (error != NRF_SUCCESS)
			{
				// Error
			}
			else
				BluetoothEventHandler((ble_evt_t *) bleEventBufferOffset);
		}
		if (!softEvent && !bleEvent)
			break;
	}
}

And in my main() I have just:

while(1)
{
	__wfi();
}

However, the BluetoothSystemEventHandler() never gets called. Is this the correct way to do it? Thanks again.

Parents
  • It seems it is the while loop waiting for the state to change. This is what I have in the flash write function-

    flashState = FLASH_STATE_IDLE;
    	error = sd_flash_page_erase(((NRF_FICR->CODESIZE - 3) + page));
    	if (error != NRF_SUCCESS)
    		return false;
    	
    	while (flashState == FLASH_STATE_IDLE); // If I remove this I get the event
    	if (flashState == FLASH_STATE_ERROR)
    		return false;
    

    If I remove the while loop, I do get the event. How can I change the while loop to wait for status change? Thanks.

Reply
  • It seems it is the while loop waiting for the state to change. This is what I have in the flash write function-

    flashState = FLASH_STATE_IDLE;
    	error = sd_flash_page_erase(((NRF_FICR->CODESIZE - 3) + page));
    	if (error != NRF_SUCCESS)
    		return false;
    	
    	while (flashState == FLASH_STATE_IDLE); // If I remove this I get the event
    	if (flashState == FLASH_STATE_ERROR)
    		return false;
    

    If I remove the while loop, I do get the event. How can I change the while loop to wait for status change? Thanks.

Children
No Data
Related