HI,.
The function below writes 8 bytes to a flash location 0X0D2660 (0XAA,0X55,,,) which is 64bit aligned and then it erases it and writes 0x14,0x13,0x12......to the same location
then I read the location 0x0d2660 and I observe FTFC_FERSTAT remains 0 ( does not report an error)after the read to the location.
This function flsh_ecc (please see below)run out of RAM from 0x1FFE0000 which is at top of the ram also the debugger shows me the 1st phrase is written and then erased and rewritten with a new phrase correctly.
then I read the location:
myvar = *((unsigned long long*)0xd2660);
the only thing which is notable is :the code triggers a BUS FAULT exception and won't run anymore.
void flsh_ecc(void)
{
//while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) != FTFC_FSTAT_CCIF_MASK); /* Wait until any ongoing flash operation is completed */
#pragma asm
;ldr r1, =0x40020000 (0x1fff027c <run_ocs_volt_once..C.3A.5CFramework_ZERV_v00.2E02.5CApplications.5CZERV_Framework.5CAppl.5Cobj.5CINF_CDD.>)
movw r1,0x0000
movt r1,0x4002
movs r0, #128 ; 0x80
strb r0, [r1, #0]
L1:
ldrb r0, [r1, #0]
lsls r0, r0, #24
bpl L1
#pragma endasm
//FTFC->FSTAT = FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_FPVIOL_MASK;
FTFC->FCCOB[3] = 0x07;//a_cmd; //Program Phrase command (0x07)
FTFC->FCCOB[2] = 0x0d;//v_AddrVec[0]; //Flash address [23:16]
FTFC->FCCOB[1] =0x26; //v_AddrVec[1]; //Flash address [15:08]
FTFC->FCCOB[0] =0x60; //v_AddrVec[2]; //Flash address [7:0]
// if (a_pageBuffer != NULL) {
FTFC->FCCOB[7] =0x55; //a_pageBuffer[0]; //data
FTFC->FCCOB[6] = 0xaa;//a_pageBuffer[1];
FTFC->FCCOB[5] = 0x55;//a_pageBuffer[2];
FTFC->FCCOB[4] =0xaa; //a_pageBuffer[3];
FTFC->FCCOB[11] =0x55; //a_pageBuffer[4];
FTFC->FCCOB[10] =0xaa; //a_pageBuffer[5];
FTFC->FCCOB[9] =0x55; //a_pageBuffer[6];
FTFC->FCCOB[8] =0xaa; //a_pageBuffer[7];
// }
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
//while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) != FTFC_FSTAT_CCIF_MASK);
#pragma asm
;ldr r1, =0x40020000 (0x1fff027c <run_ocs_volt_once..C.3A.5CFramework_ZERV_v00.2E02.5CApplications.5CZERV_Framework.5CAppl.5Cobj.5CINF_CDD.>)
movw r1,0x0000
movt r1,0x4002
movs r0, #128 ; 0x80
strb r0, [r1, #0]
L2:
ldrb r0, [r1, #0]
lsls r0, r0, #24
bpl L2
#pragma endasm
FTFC->FCCOB[3] = 0x09;//a_cmd; //Program Phrase command (0x07)
FTFC->FCCOB[2] = 0x0d;//v_AddrVec[0]; //Flash address [23:16]
FTFC->FCCOB[1] =0x26; //v_AddrVec[1]; //Flash address [15:08]
FTFC->FCCOB[0] =0x60; //v_AddrVec[2]; //Flash address [7:0]
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
#pragma asm
;ldr r1, =0x40020000 (0x1fff027c <run_ocs_volt_once..C.3A.5CFramework_ZERV_v00.2E02.5CApplications.5CZERV_Framework.5CAppl.5Cobj.5CINF_CDD.>)
movw r1,0x0000
movt r1,0x4002
movs r0, #128 ; 0x80
strb r0, [r1, #0]
L3:
ldrb r0, [r1, #0]
lsls r0, r0, #24
bpl L3
#pragma endasm
FTFC->FCCOB[3] = 0x07;//a_cmd; //Program Phrase command (0x07)
FTFC->FCCOB[2] = 0x0d;//v_AddrVec[0]; //Flash address [23:16]
FTFC->FCCOB[1] =0x26; //v_AddrVec[1]; //Flash address [15:08]
FTFC->FCCOB[0] =0x60; //v_AddrVec[2]; //Flash address [7:0]
// if (a_pageBuffer != NULL) {
FTFC->FCCOB[7] =0x10; //a_pageBuffer[0]; //data
FTFC->FCCOB[6] = 0x12;//a_pageBuffer[1];
FTFC->FCCOB[5] = 0x13;//a_pageBuffer[2];
FTFC->FCCOB[4] =0x14; //a_pageBuffer[3];
FTFC->FCCOB[11] =0x15; //a_pageBuffer[4];
FTFC->FCCOB[10] =0x16; //a_pageBuffer[5];
FTFC->FCCOB[9] =0x17; //a_pageBuffer[6];
FTFC->FCCOB[8] =0x18; //a_pageBuffer[7];
//INT_SYS_EnableIRQGlobal();
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; //launch command
#pragma asm
;ldr r1, =0x40020000 (0x1fff027c <run_ocs_volt_once..C.3A.5CFramework_ZERV_v00.2E02.5CApplications.5CZERV_Framework.5CAppl.5Cobj.5CINF_CDD.>)
movw r1,0x0000
movt r1,0x4002
movs r0, #128 ; 0x80
strb r0, [r1, #0]
L4:
ldrb r0, [r1, #0]
lsls r0, r0, #24
bpl L4
#pragma endasm
}
Just wondering beside the register FTFC-FEPRT, is it some else to check.
BR,
Koorosh Hajiani