Tool/software:
Hello Skyler Baumer,
We are using Flash sector12 to store the calibration information. We are referring Flash API guide for writing the data into Flash and reading the data from Flash memory.
The Read data from Flash API is not available in the user guide. However, we are experiencing an issue while reading the data from flash memory.
Specifically, when CALIB_DATA_SIZE is set to 128 or 256, the data is read correctly as expected. On the other hand, when CALIB_DATA_SIZE is set to more than 2048, the initial few locations are copied correctly, but later locations contain garbage data.
Code used to read flash memory and copy it into RAM:
#define CALIB_DATA_SIZE 128
#define CALIB_RAM_CONFIG_ADDRESS 0x0000E000
void LoadConfigFromFlash(void)
{
uint32 i = 0;
// Initialize Read Buffer
uint16 Calib_Read_Buffer[CALIB_DATA_SIZE] = {0};
uint16 *Calib_Pointer;
Calib_Pointer = (uint16 *) (CALIB_SECTOR_START_ADDR);
// Transfer contents of flash sector to Read Buffer
for(i=0;i<CALIB_DATA_SIZE;i++)
{
Calib_Read_Buffer[i] = *(Calib_Pointer++);
}
// Copy data to RAM
memcpy((void *)CALIB_RAM_CONFIG_ADDRESS, Calib_Read_Buffer, CALIB_DATA_SIZE);
}
Is there a standard API available to read sector data from flash memory or could you please provide an example code for Read the data from Flash memory?