porf (power-on reset flag) setting condition - MC9S12D128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

porf (power-on reset flag) setting condition - MC9S12D128

2,007 Views
D64
Contributor I
Hi, there,
 
I am using S12-D128. what is the set condition of porf bit? I use PEMicro debugger to reflash the code. I expect the bit to be set. But actually not. Is there any way I could make it set and under control of debugger?
Thanks
 
 
 
 
Added p/n to subject. . 


Message Edited by NLFSJ on 2008-10-30 07:15 PM
Labels (1)
0 Kudos
Reply
2 Replies

956 Views
Sany
Contributor III

Hi, just want to add up to here for others' reference.

I had the almost similar issue which bring me to this thread.

After looking at Edward Karpicz, I checked through my code which found following:

  1. RESET_MONITOR:      BRCLR   CRGFLG,#LVRF,RESET_MONITOR1 ;check if this is power reset / low voltage reset
  2.                     BSET    CRGFLG,#LVRF          ;clear the flag
  3.                     ;do something with low voltage reset
  4. RESET_MONITOR1:     BRCLR   CRGFLG,#PORF,RESET_MONITOR9
  5.                     BSET    CRGFLG,#PORF          ;clear the flag
  6.                     ;do something with power reset detection
  7.                     MOVB    #ATR_PWR_RESET,ADDATR_CODE
  8.                     BRA     RESET_MONITOR2
  9. RESET_MONITOR9:     MOVB    #ATR_WDOG_RESET,ADDATR_CODE
  10. RESET_MONITOR2:     JSR     ADD_ATRANS
  11.                     RTS

which has the flaw on line 2 and cost the line 4 flag being cleared before even being detect. After change it to following:

  1. RESET_MONITOR:      BRCLR   CRGFLG,#LVRF,RESET_MONITOR1 ;check if this is power reset / low voltage reset
  2.                     BCLR    CRGFLG,#LOW(~LVRF)          ;clear the flag
  3.                     ;do something with low voltage reset
  4. RESET_MONITOR1:     BRCLR   CRGFLG,#PORF,RESET_MONITOR9
  5.                     BCLR    CRGFLG,#LOW(~PORF)          ;clear the flag
  6.                     ;do something with power reset detection
  7.                     MOVB    #ATR_PWR_RESET,ADDATR_CODE
  8.                     BRA     RESET_MONITOR2
  9. RESET_MONITOR9:     MOVB    #ATR_WDOG_RESET,ADDATR_CODE
  10. RESET_MONITOR2:     JSR     ADD_ATRANS
  11.                     RTS


everything work as expected. Hope this help.

0 Kudos
Reply

956 Views
kef
Specialist I
Are you using RTI (real time interrupt)? Or maybe any code that write accesses RTIF, LOCKIF or SCMIF bits? If yes, then please show how are you clearing all these bits.
PORF bit is set on power on reset. Once cleared, it won't get set again until you cycle the power of your MCU.
0 Kudos
Reply