Hello,
I am new to using the S32K146 board and I'm trying to store some data in the D-Flash memory. I have used the following code from the "Example_S32K144-Flash_RW_simple-S32DS12" example to erase a sector and program some data, which looks like its storing in memory successfully.
But looking at the Memory Map for the S32K146 it looks like this is storing data into the PFlash memory (0x0 - 0x03FFFFFF) with the DFlash memory starting at 0x10000000. But below the FTFC->FCCOB register doesn't have a setting for the upper byte of the flash address (31:24) which would be needed to access the DFlash memory?
Any help would be much appreciated, apologies if I'm missing something obvious.
void EraseAndProgram(void)
{
//erase 4KB flash sector (the smallest entity that can be erased) at 0x0004_0000
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); //wait if operation in progress
FTFC->FSTAT = FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_FPVIOL_MASK; //clear flags if set
FTFC->FCCOB[3] = 0x09; //Erase Flash Sector command (0x09)
FTFC->FCCOB[2] = 0x04; //Flash address [23:16]
FTFC->FCCOB[1] = 0x00; //Flash address [15:08]
FTFC->FCCOB[0] = 0x00; //Flash address [7:0]
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); //wait for done
//program phrase at address 0x0004_0000
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); //wait if operation in progress
FTFC->FSTAT = FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_FPVIOL_MASK;
FTFC->FCCOB[3] = 0x07; //Program Phrase command (0x07)
FTFC->FCCOB[2] = 0x04; //Flash address [23:16]
FTFC->FCCOB[1] = 0x00; //Flash address [15:08]
FTFC->FCCOB[0] = 0x00; //Flash address [7:0]
FTFC->FCCOB[7] = 0xFE; //data
FTFC->FCCOB[6] = 0xED;
FTFC->FCCOB[5] = 0xFA;
FTFC->FCCOB[4] = 0xCE;
FTFC->FCCOB[11] = 0xCA;
FTFC->FCCOB[10] = 0xFE;
FTFC->FCCOB[9] = 0xBE;
FTFC->FCCOB[8] = 0xEF;
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0); //wait for done
}