Hi everybody, i am working with a nrf51822. S110 with sdk6.1 IDE:keil
I want to do FLASH Erase while in a connection. I have read this page devzone.nordicsemi.com/.../ and found out that the fail is related to the connection interval.It have to sufficiently long for flash to erase. I changed the value of MAX_CONN_INTERVAL to 100 (125ms),but it doesn't work at all. Please ,does anyone have any suggestion for this question ?Thank you for any help.
below is my code int main(void) {
static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
static uint8_t index = 0;
uint8_t index_backup = 0;
uint8_t newbyte;
leds_init();//BLE LED
timers_init();
buttons_init();
uart_init();
ble_stack_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
sec_params_init();
//advertising_start();
uint32_t *addr;
uint8_t patwr;
uint8_t patrd;
uint8_t patold;
uint32_t i;
uint32_t pg_size;
uint32_t pg_num;
init();//gpio read port and output port
patold = 0;
pg_size = NRF_FICR->CODEPAGESIZE;
pg_num = NRF_FICR->CODESIZE - 1; // Use last page in flash
while (true)
{
// Start address:
addr = (uint32_t *)(pg_size * pg_num);
// Erase page:
flash_page_erase(addr);
i = 0;
while (1)
{
nrf_delay_ms(1000);
flash_page_erase(addr);
// Read pattern from port 0 (pins0-7), and write it to flash:
patwr = nrf_gpio_port_read(NRF_GPIO_PORT_SELECT_PORT0);
flash_word_write(addr, (uint32_t)patwr);
// Read pattern from flash and write it to port 1 (pins8-15):
patrd = (uint8_t)*addr;
nrf_gpio_port_write(NRF_GPIO_PORT_SELECT_PORT1, patrd);
}
}
}