Hi to community again!
I'm having trouble with TWIS during page erase on nRF52840 (FICR "Read 4 bytes @ address 0x10000104 (Data = 0x41414330)") as the bus is stalled while waiting for IRQ handler to be called. Product specification says "The CPU is halted IF the CPU executes code FROM THE FLASH while the NVMC is writing to the flash." So I've moved critical parts to RAM already and verified it is really called called from RAM but the TWI bus is still being stalled during page erase. It seems CPU is halted regardless the code source or there is something else I've missed.
Moved isr vector to RAM and redirected VTOR:
#define VECTOR_TABLE_SIZE 0x200
static uint32_t vector_table_ram[VECTOR_TABLE_SIZE] __attribute__((aligned (128)));
int main(void)
{
memcpy(vector_table_ram, (uint32_t *)&__isr_vector, VECTOR_TABLE_SIZE);
__disable_irq();
SCB->VTOR = (uint32_t)&vector_table_ram;
__enable_irq();
TWIS IRQ handler inf nrfx_twis.c:
__attribute__((used, long_call, section(".RAMfunc"))) void nrfx_twis_0_irq_handler(void)
{
nrf_gpio_pin_set(24U);
nrfx_twis_state_machine(NRF_TWIS0, &m_cb[NRFX_TWIS0_INST_IDX]);
nrf_gpio_pin_clear(24U);
}
Page erase function in nrf_nvmc.c
__attribute__((used, long_call, section(".RAMfunc"))) void nrf_nvmc_page_erase(uint32_t address)
{
nrf_gpio_pin_set(23U);
// Enable erase.
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een;
__ISB();
__DSB();
// Erase the page
NRF_NVMC->ERASEPAGE = address;
wait_for_flash_ready();
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
__ISB();
__DSB();
nrf_gpio_pin_clear(23U);
}
But scope output is still like this (first line SDA, second SCL, third high when inside twis handler in application, fourth high when inside IRQ handler, fifth high when in page erase func):

Any help is really appreciated! Thanks.