I want to protect the programme and data in the flash memory from being rewritten during shipment.
I thought that I could set the NVMC register, CONFIG, to read-only, so I executed the following programme to try it out.
-----------------------------
static void flash_page_init_no(void)
{
m_data.pg_num = NRF_FICR->CODESIZE - 1;
m_data.pg_size = NRF_FICR->CODEPAGESIZE;
m_data.addr = (m_data.pg_num * m_data.pg_size);
m_data.m_p_flash_data = (flashwrite_flash_data_t *)m_data.addr;
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
nrf_nvmc_page_erase(m_data.addr);
return;
}
-----------------------------
However, despite being read-only, I was able to erase the data normally without an error, which I confirmed by looking at the memory map in the debug mode of SEEGER.
--Why is it possible to erase even though it is read-only?
--Can't I just set the registers to protect them? How can I erase or prohibit writing?
