Hi,Sir
Thanks for your help.
I have 2 question:
1.
I modified the code as followed.
Just like code:
;IN BDM nmode,must use these 2 lines. It will write the flash sucessfully(I can find the data in debug momory window)
ldab #48
stab FSTAT;Use store instruction to clear ACCERR, FPVIOL.
if I use the following code:
bset FSTAT,#mFSTAT_ACCERR
bset FSTAT,#mFSTAT_FPVIOL
Data can not been writen into flash.
But in NS mode,I must use these 2 lines,or crash.
bset FSTAT,#mFSTAT_ACCERR
bset FSTAT,#mFSTAT_FPVIOL
2.
IN BDM,I muse use memory data
rgOfRam:dc.b $1C,$01,$06,$80,$1F,$01,$06,$80,$FB,$3D, to replace the following code:
bset FSTAT,#mFSTAT_CCIF
Wait_CCIF:
brclr FSTAT,#mFSTAT_CCIF,Wait_CCIF;if this bit is 0x0,wait here. Wait a while for CCIF to be set
But in NS,if i use PrgOfRam,the code will crash.
I must use these 3 lines in NS.
bset FSTAT,#mFSTAT_CCIF
Wait_CCIF:
brclr FSTAT,#mFSTAT_CCIF,Wait_CCIF;if this bit is 0x0,wait here. Wait a while for CCIF to be set
But this way,NS can not write the data into flash successfully.
Please check the following code.
Thanks for your help.
Please give me support when you are free. I am urgent about it.
;*************************************************************************************************************
;stack to store parameter.
;Here parameters:
;1,params(byte); 2, ccob0high(byte); 3 ccob0low(byte);4 ccob1(word);5 ccob2(word);6 ccob3(word);7 ccob4(word);
;8 ccob5(word);9 ccob6(word);10 ccob7(word);
;LaunchComBuff: fixed memory to Program flash,the above parameter store in it.
LaunchFlashCommand: equ *
;pshd
;pshx
;pshy
leax LaunchComBuff,pcr
Wait_CCIF0:
brclr FSTAT,#mFSTAT_CCIF,Wait_CCIF0;if this bit is 0x0,wait here. Wait a while for CCIF to be set
;brclr FSTAT,#mFSTAT_CCIF,ret_Launch;
;BDM,must use these 2 lines. or CAN not write into flash.
;ldab #48
;stab FSTAT;Use store instruction to clear ACCERR, FPVIOL.
;NS,must use these 2 lines.or crash.
bset FSTAT,#mFSTAT_ACCERR
bset FSTAT,#mFSTAT_FPVIOL
;**********SET UP THE FTM COMMAND AND PARAMETERS***********
bclr FCCOBIX,#mFCCOBIX_CCOBIX0
bclr FCCOBIX,#mFCCOBIX_CCOBIX1
bclr FCCOBIX,#mFCCOBIX_CCOBIX2
;clra
ldab 1,x
stab FCCOBHI
;inca
ldab 2,x
stab FCCOBLO
ldab 0,x
beq Con_Oper;if param == 0,return
ldaa #$03
Write_CCOB:
nop
nop
inc FCCOBIX
ldy a,x
sty FCCOB;Write next word parameter to CCOB1 buffer.
inca
inca
decb ;because register store param number
beq Con_Oper;if b is 0,return
bra Write_CCOB
Con_Oper:
;BMD,use the following code,write ok.
jmp PrgOfRam,pcr
;NS,use the following code,CAN communication is okay,but not write ok.
;bset FSTAT,#mFSTAT_CCIF
;Wait_CCIF:
; brclr FSTAT,#mFSTAT_CCIF,Wait_CCIF;if this bit is 0x0,wait here. Wait a while for CCIF to be set
ret_Launch:
;puly
;pulx
;puld
rts
;LaunchFlashCommand
;*************************************************************************************************************