I can't get Flash_Erase() to work. In main I setup this test code:
//-------------------------------------------------------------------------------------------
//--- Function: main()
void main(void)
{
//--- Initialization
InitSysCtrl(); // Initialize the CPU (FILE: SysCtrl.c)
InitGpio(); // Initialize the shared GPIO pins (FILE: GPIOinit.c)
InitPieCtrl(); // Enable the PIE (FILE: PieCtrl.c)
InitAdc(); // Initialize the ADC (FILE: ADCinit.c)
InitEPwm(); // Initialize the EPwm (FILE: EPWMinit.c)
InitECap(); // Initialize the ECap (FILE: ECAPinit.c)
InitECan(); // Initialize the CAN (FILE: CANinit.c)
//--- Copy all FLASH sections that need to run from RAM (use memcpy() from RTS library)
//--- Section secureRamFuncs contains user defined code that runs from CSM secured RAM
memcpy(&secureRamFuncs_runstart, &secureRamFuncs_loadstart, &secureRamFuncs_loadend - &secureRamFuncs_loadstart);
// memcpy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);
memcpy(&Flash28_API_runstart, &Flash28_API_loadstart, (Uint32)(&Flash28_API_loadsize));
Flash_CPUScaleFactor = SCALE_FACTOR;
Flash_CallbackPtr = NULL;
//--- Initialize the FLASH
InitFlash(); // Initialize the Flash (FILE: Flash.c)
//--- Enable the Watchdog interrupt
// PieCtrlRegs.PIEIER1.bit.INTx8 = 1; // Enable WAKEINT (LPM/WD) in PIE group #1
// IER |= 0x0001; // Enable INT1 in IER to enable PIE group 1
//--- Check Version
Version = Flash_APIVersion();
if(Version != (float32)3.02)
{
asm(" ESTOP0");
}
//--- Make sure the PLL is not running in limp mode
if (SysCtrlRegs.PLLSTS.bit.MCLKSTS == 1)
{
asm(" ESTOP0");
}
//--- Verify the CSM is unlocked
if ( (CsmRegs.CSMSCR.all & 0x0001) != 0)
{
asm(" ESTOP0");
}
//--- Toggle Test use GPIO14
// GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0;
// GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
// Flash_ToggleTest(&GpioDataRegs.GPATOGGLE.all, (Uint32)0x00004000);
Status = Flash_Erase(SECTORA,&FlashStatus);
if(Status != STATUS_SUCCESS)
{
asm(" ESTOP0");
}
I have run Flash_ToggleTest() and get the 10kHz signal. The code runs without breaking at the ESTOPs. I get Status = 0 after I run the code. When I use CCS 3.3.38 View Memory I find the original data still in the sector?!?