AnsweredAssumed Answered

My code will crash in normal mode.But ok under SS mode.

Question asked by li cang on Apr 23, 2010
Latest reply on Apr 26, 2010 by li cang

The code is here:

;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:
  ;pshd
  ;pshx
  ;pshy
  leax LaunchComBuff,pcr
  ;jsr Delay32nop,pcr
  ;check FCLKDIV&0x80
  ldaa FCLKDIV
  brset FCLKDIV,#mFCLKDIV_FDIVLD,Wait_CCIF0 ;if set,jump
                                      ;else,run here
  ldaa #FCLK_DIV_4M                                     
  staa FCLKDIV
  ;if(FCLKDIV != (FCLK_DIV | 0x80))//Check to make sure value is written.
  ;ReportError(0);
  oraa  #$80
  cmpa FCLKDIV;check FCLKDIV is FCLK_DIV | 0x80
  bne ret_Launch;if not equ,return
 ; jsr Delay32nop,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;
 
  ldaa #$030
  staa FSTAT;Use store instruction to clear ACCERR, FPVIOL.
 ; jsr Delay32nop,pcr
  ;**********SET UP THE FTM COMMAND AND PARAMETERS***********
 
  clr FCCOBIX
  ;clra
  ldab 1,x
  stab FCCOBHI
  ;inca
  ldab 2,x
  stab FCCOBLO
  ldab 0,x
  beq Con_Oper;if param == 0,return

  ldaa #$03 
  ;jsr Delay32nop,pcr
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

;The code in flash 
;Con_Oper:  
;  ldaa #$80
;  staa FSTAT
;Wait_CCIF:
;  brclr FSTAT,#mFSTAT_CCIF,Wait_CCIF    ;while (!FSTAT_CCIF);
Con_Oper:
  jsr PrgOfRam,pcr
       
wait_Here:
  brset FSTAT,#mFSTAT_ACCERR,wait_Here
  brset FSTAT,#mFSTAT_FPVIOL,wait_Here
  brset FSTAT,#mFSTAT_MGSTAT1,wait_Here
  brset FERSTAT,#mFERSTAT_ERSERIF,wait_Here
  brset FERSTAT,#mFERSTAT_PGMERIF,wait_Here
  brset FERSTAT,#mFERSTAT_EPVIOLIF,wait_Here
  brset FERSTAT,#mFERSTAT_ERSVIF1,wait_Here
  brset FERSTAT,#mFERSTAT_DFDIF,wait_Here
  brset FERSTAT,#mFERSTAT_SFDIF,wait_Here
  ;jsr Delay32nop,pcr


ret_Launch:
  ;puly
  ;pulx
  ;puld
  rts
;LaunchFlashCommand
;*************************************************************************************************************

 

 

It can run normally under BDM mode,but it will crash when we run it in normal mode.

Please help me.Thanks.

Outcomes