Hi all,
I have a problem about flash programming for MCF51EM256. I downloaded application note by AN3942 document number and also downloaded software by AN3942SW number. And then I followed the instructions (also set my flash clock). My erase function is running perfectly but my burst program is not. It is writing my datas to the given address but it can not jump to subroutine. Here are the burst code from AN3942SW;
/*******************************************************************************/
_Burst_Prog:
move.l d0,d4
move.l a1,a3
move.l a0,d2
move.l a0,d6
cmpi.l #0x1FFFF,d6
bgt.s SEC_ROUT2
move.l #(SpSubBurstEnd),a1
move.l #(SpSubBurst),a6
bra DOONSTACK2
SEC_ROUT2: move.l #(SpSubBurstEnd2),a1
move.l #(SpSubBurst2),a6
DOONSTACK2: bsr DoOnStack
cmpi.l #0x1FFFF,d6
bgt.s SECOND_BLOCK2
FIRST_BLOCK2:
move.l a0,a1
move.b #(mF1STAT_FCCF + mF1STAT_FCBEF),d0
move.b d0,F1STAT
bra JMP_STACK2
SECOND_BLOCK2:
move.l a0,a1
move.b #(mF2STAT_FCCF + mF2STAT_FCBEF),d0
move.b d0,F2STAT
JMP_STACK2:
jsr (A1) //The problem is here
rts
/*******************************************************************************/
DoOnStack:
move.l A7,A2 /* save actual address SP */
DoOnStack1:
suba.l #2,a7
move.w (a1),d0
move.w d0,(A7)
cmpa.l a6,a1 /* SELECTED #(SpSubBurst) or #(SpSub) */
suba.l #2,a1
bne.s DoOnStack1
move.l A7,A0
move.l A2,A7
rts
/*******************************************************************************/
What sould I do?
Thank you,
Nur
It is weird that _Burst_Prog is trying to launch flash command by writing one to FCBEF bit. If this attempt is accepted by flash controller, then CPU should runaway, because _Burst_Prog is probably in flash and flash is not readable while being programmed, CPU can't read opcodes etc. Writing one to FCBEF should be done only in one of Spxxxx routines, which are copied by DoOnStack routine to RAM(stack). Maybe they ware trying to clear FPVIOL and FACCERR bits? Try commenting out in _Burst_Prog
move.b d0,F1STAT
and
move.b d0,F2STAT
or replace
move.b #(mF1STAT_FCCF + mF1STAT_FCBEF),d0
and
move.b #(mF2STAT_FCCF + mF2STAT_FCBEF),d0
with
move.b #(mF1STAT_FPVIOL + mF1STAT_FACCERR),d0
and
move.b #(mF2STAT_FPVIOL + mF2STAT_FACCERR),d0
Thank you, but the problem is still remaining...