Hi Everyone,
I am having problems writing to an array in NRF52832 without causing the program crashing at run time.
I declare the array to be 512 uint8_t long
static uint8_t badBlockTable[512];
then I copy data into the array using FlashPageRead, which reads a page from the NAND flash at a particular address and copies it into the array.
do { for (uint8_t i = 0; i < 2; i++) { Build_Address(block_tmp, page_tmp, col_tmp, & addr_tmp); err = FlashPageRead(addr_tmp, & badBlockTable[200 * i], 200); //copy data straight to array col_tmp += 200; } Build_Address(block_tmp, page_tmp, col_tmp, & addr_tmp); err = FlashPageRead(addr_tmp, & badBlockTable[400], 112); //copy data straight to array j++; if (j >= 4) { NRF_LOG_INFO("Error reading bad block table"); NRF_LOG_FLUSH(); break; } block_tmp = bbt_addr[j]; col_tmp = 0; } while (err != 0);
From the code above you can see I call FlashPageRead three times to first copy 2*200 bytes of data then the last 112 bytes of data.
However when I do this the program would crash from what I suspect to be memory out of bounds exception, if I increase the allocation of array to 520 instead of 512
then the program would run fine.
Does anyone know what's causing this?
Thanks for the help!