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

nRF51822 FLASH Erase Error

nRF51822 DK. Keil can download program. But in my pragram, when receive a UART command to erase FLASH page 248, use ble_flash.c

static void flash_page_erase(uint32_t * p_page)
{
  // Turn on flash erase enable and wait until the NVMC is ready.
  NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);
  while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
  {
    // Do nothing.
  }
 
  // Erase page.
  NRF_NVMC->ERASEPAGE = (uint32_t)p_page;
  while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
  {
    // Do nothing.
  }

  nrf_gpio_pin_clear(NRF6310_LED_4);

  // Turn off flash erase enable and wait until the NVMC is ready.
  NRF_NVMC->CONFIG &= ~(NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);
  while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
  {
    // Do nothing
  }
}

can't execute to nrf_gpio_pin_clear(NRF6310_LED_4); also keil stop! **JLink Warning: T-bit of XPSR is 0 but should be 1. Changed to 1.

But in another project \nrf6310\flashwrite_example it's OK.

why?

Parents
  • I have found it! It's BLE radio active while FLASH Erase! Because Erase Page in FLASH memroy need time(21ms type), radio notificatio can't guarantee safely operate. example: if first Erase FLASH Page while radio not active, then during 21ms radio avtive.

Reply
  • I have found it! It's BLE radio active while FLASH Erase! Because Erase Page in FLASH memroy need time(21ms type), radio notificatio can't guarantee safely operate. example: if first Erase FLASH Page while radio not active, then during 21ms radio avtive.

Children
  • Good! I didn't realize that you were also doing BLE communication when this failed.

    Feel free to accept your own answer, by clicking the button below your answer! This will make it easier for others to find the solution. :-)