MC9S12D64 - Restart Cause

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

MC9S12D64 - Restart Cause

2,260 Views
BFS
Contributor I
Hi,
For MC9S12D64, can I understand the restart cause of microcontroller by using microcontroller hardware (which one of them : normal power up - master clear reset - watchdog reset).
Thanks...

--
Alban Edit: FSL Part Number must figure in Message Subject line.



Message Edited by Alban on 2007-07-21 07:54 PM
Labels (1)
0 Kudos
4 Replies

512 Views
Shugie
Contributor I
Rereading your message I think I missed what I was trying to say. Those VECTOR definitions go to various functions, so if you wanted to you could do


VECTOR 0 Function1
VECTOR 2 Function2

Have the functions do their debugging stuff and then have them call your main program loop. I hope this is more helpful.
0 Kudos

512 Views
BFS
Contributor I
Thanks for replies. They were vey helpful.
BFS
0 Kudos

512 Views
kef
Specialist I
Power up  vs  /RESET pin reset can be distinguished using PORF bit ( CRGFLG register, CRG module). Power up makes PORF this bit. And you clear it. So immediately after reset
 
1) you read PORF bit value. '1' means power up reset, '0' - not power up reset.
2) you have to clear PORF bit by writing '1' to it.
 

COP reset , CME reset and all other resets (/RESET pin reset and power on reset) use 3 different reset vectors. So to make it different, all these 3 vectors should point do different entry points. If you are coding in C then you could write 3 functions (entry points) that could pass different value of reset type to common startup function. Somethink like this:
 
 
enum {  PONRESET, EXTERNRESET, COPRESET, CMERESET };
 
mainreset()
{
   init_stack_pointer;
 
    // is PORF set?
   if(CRGFLG & 0x40)  startup(PONRESET);
   else                           startup(EXTERNRESET);
}
 
 
copreset()
{
   init_stack_pointer;
  
   startup(COPRESET);
}
 
cmereset()
{
   init_stack_pointer;
 
   startup(CMERESET);
}
 
startup(int resettype)
{
   CRGFLG &= 0x40;
 
  ...
}
 
 
 
Note that to make CME and COP reset vectors working you should have proper circuit on /RESET pin. See chapter CRG Block User Guide,  5.2 Description of Reset Operation for details.  In short, on reset MCU drives /RESET pin low, then, after few cycles, MCU samples /RESET pin to make sure was it external reset or internal reset. So you can't have large cap on /RESET pin. Also you shouldn't use something like DS1813 for brown-out protection. If you do so then  MCU will be sort of unable to fetch COP or CME vectors.
 
 
 
0 Kudos

512 Views
Shugie
Contributor I
Hi, I use the C32 chip and have just recently been trying to learn the resets. There should be a page in the manual early on about where resets go in physical memory. The power up and hardware resets go to 0xFFFE and the watchdog goes to 0xFFFC on my chip. Check chapter 1 of your manual for "resets" or "vectors". The way I implemented it in code is in the Startup.c file that Codewarrior provides that does all initilizations, I have this code

VECTOR 0 _Startup
VECTOR 2 _Startup

This restarts my program on a hardware reset and a watchdog reset. I'm not exactly sure of the definitions, so hopefully another freescaler can explain in more detail.

Message Edited by Shugie on 2007-07-20 09:39 AM
0 Kudos