Hello;
I am working on S12XEP100 bootloader from AN4258SW and I have a problem with erasing flash. The program stuck when address of erasing reaches to 0x007D0000. So I wrote a simple application for finding problem. about my app:
-I don't have any interrupt (and ISR) in this app.
-My program resides from 0xB000-0xFFFF to FLASH and 0x3800-0x3FFF to RAM.
-stack pointer to 0x3900.
-IVBR to 0x3F00
here is my app and again it stuck in 0x007D0000:
void main(void) {
PLL_Init(SYNR_VALUE, REFDV_VALUE, POSTDIV_VALUE); //set 50MHz BUSCLK
while((FSTAT & FSTAT_CCIF_MASK) == 0);
FCLKDIV = FLASH_PRESCALER; //set flash prescaler
InterruptModuleSetup();
InitSCI();
//CopyCodeToRAM();
DDRA = 0xff; // all output
DDRM = 0xff; // all output
PORTA = 0x00;
PTM = 0x00;
UINT32 Address;
for(Address = 0x00780000UL; Address < 0x007E0000UL; Address += 0x400)
{
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait if command in progress
FSTAT = 0x30; //clear ACCERR and PVIOL
FCCOBIX = 0x00; // set FCMD
FCCOBHI = 0x0A;
FCCOB = 0x0A00 | ((Address & 0x00FF0000)>>16);
FCCOBIX = 0x01;
FCCOB = (Address & 0x0000FFF8);
FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait for done
}
PORTA = 0xff;
PTM = 0xff;
for(;;)
{
}
}
and this is my linker (in IAR Embedded workbench):
-chcs12
//================================================================
// Heap and Stack
//================================================================
// Size of the user stack
-D_CSTACK_SIZE=100
// Size of the heap
-D_HEAP_SIZE=000
//================================================================
// Memory Definitions
//================================================================
// Memory areas available for the application
-D_RAM_BEGIN=03900
-D_RAM_END=03Eff
-D_ROM_BEGIN=B000
-D_ROM_END=FEFF
//================================================================
// Memory Placement
//================================================================
/////////// FLASH
-Z(CODE)INTVEC=3F00-3FFF // interrrupt vectors = 0x3F
-Z(CODE)CODE,EARLYDIFUNCT,DIFUNCT,INITTAB,DATA16_C,DATA8_ID,DATA16_ID,CHECKSUM=_ROM_BEGIN-_ROM_END
//*************************************************************************
////////// RAM
-Z(DATA)DATA8_I,DATA8_Z,DATA8_N=00-FF
-Z(DATA)DATA8_C
-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,HEAP+_HEAP_SIZE=_RAM_BEGIN-_RAM_END
-Z(DATA)CSTACK+_CSTACK_SIZE=3800-38FF //stack placement
//*************************************************************************
regard
Mohammad.