For our project we are currently using the RSL10 evaluation board RSL10 SIP.
For our needs I need to save 60KB of data, so we decided to use the onchip flash, form the documentation provided I assume that the flash memory occupancy of the boot loaded, fota and .bin images are continuous, so I decided to start writing on to Flash from 280KB boundary, so my effective start address for data should be “FLASH_MAIN_BASE+0x46000”, when I am trying to erase and write to the area my system is stuck. Below is my code function.
The same system stuck happens when I try to access NVR1 memory and write to it.
From the debugger stepping through the code I see that the program is stuck in the following line in the rsl10_flash.c
/* Wait until the write is completed and new words can be provided */ while (FLASH_IF_STATUS->PROG_SEQ_DATA_REQ_ALIAS == 0);
Is there something that I am missing?
Any help is appreciated.
#define FLSHDATABASEADDR (FLASH_MAIN_BASE+0x46000)
void writeTOFlash(uint8_t *buff, uint8_t length)
flshaddr = FLSHDATABASEADDR;
uint8_t i =0;
wrBuff[i] = buff[i+3]<<24;
wrBuff[i] |= buff[i+2]<<16;
wrBuff[i] |= buff[i+1]<<8;
wrBuff[i] |= buff[i];
length = length-4;
bool ret = false;
FLASH->MAIN_CTRL = MAIN_LOW_W_ENABLE | MAIN_MIDDLE_W_ENABLE | MAIN_HIGH_W_ENABLE;
FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
uint32_t flshdelay = FLASH->DELAY_CTRL;
flshdelay|=0x09; // Flash delay as suggested in [KB: Setting the Flash Delay to Ensure Read & Write Operations are Successful]
FLASH->DELAY_CTRL = flshdelay;
__disable_irq(); ret = Flash_EraseSector(flshaddr); __enable_irq(); __disable_irq(); ret = (Flash_WriteBuffer(flshaddr, sizeof(wrBuff), (unsigned int*)&wrBuff) == 0); __enable_irq(); bool b = (memcmp((void *)flshaddr, (unsigned int*)&wrBuff, sizeof(wrBuff)) == 0); /* Lock */ FLASH->MAIN_CTRL = 0; FLASH->MAIN_WRITE_UNLOCK = FLASH_MAIN_KEY;
wrordswritten = i;