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?

Related