CPU RESET on MC9S12XDP512

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

CPU RESET on MC9S12XDP512

4,466 Views
Pang
Contributor I
Hi everyone,
 
I have an application with MC9S12XDP512 under CW4.6. The power supply will monitor power surge or power outage.  When it occurs, it will send ACFAIL signal to XIRQ/PE0 and trigger my ISR to deal with this power surge. 25ms after ACFAIL, the power supply starts sending external RESET signal
 
My questions,
 
1. Will this external RESET cause CPU to restart immediately whenever RESET is raised?
 
1. I don't want CPU to be reset within 2 seconds since my board has super capacitor to hold power for about 5 minutes. I want to restart my application after 2 seconds power outage which is considered to be long-term power surge.
 
Do you need to do something in my ACFAIL ISR to set CRG so that my application will keep running before 2 seconds elapse.
 
Any inputs will be greatly appreciated.
 
Thanks a lot for prompt reply.
 
Pang 
Labels (1)
0 Kudos
10 Replies

821 Views
Alban
Senior Contributor II
Dear Pang,
 
Prompt reply provided.
1. Reset pin put low creates immediate Reset. It is asynchronous.
As soon as you generate a Reset, one way or another, the MCU goes into reset immediately. Up to your software to be quick to do a Reset.
 
2. Not really sure what you want to do. If there is no change in the clock, the MCU continues to run.
 
Cheers,
Alban.
0 Kudos

821 Views
Pang
Contributor I
Alban,
 
First, Thanks a lot for your quick reply.
 
There are different RESETs. Only can System RESET cause MCU to restart. My application will deal with this situation:
 
The power supply generates ACFAIL, then trigger my ACFAIL ISR in which I need backup up my data and log this as short/long-term power outage. 25ms after ACFAIL low, power supply sends EXTERNAL RESET (instead of SYSTEM RESET) to MCU and tell MCU to restart.
 
To my knowledge, when RESET in Hight (I am not sure that it means EXTERN RESET or SYSTEM RESET), MCU goes to RESTART.
 
My question, How can we prevent MCU from being restarted when EXTERNAL RESET in High before 2 seconds elapse, which means, If power goes down than 2 seconds, my application will think it is right time to restart no matter whenever powerback.
 
Please let me know if not clear.
 
Thanks,
 
Andy 
0 Kudos

821 Views
Alban
Senior Contributor II
Hey Andy,
 
The RESET pin is active low, which means a ZERO on the pin will create an immediate reset of the microcontroller.
 
To delay a MCU Reset, here is what you can do.
You connect the reset request from your power supply circuit to XIRQ or IRQ.
In the IRQ or XIRQ ISR you can start a TIMer which after 2 seconds elapse generates the MCU reset (via writing wrong value to the COP for instance).
 
Did I understand what you mean ?
Alban.
0 Kudos

821 Views
Pang
Contributor I
Dear Alan,
 
Power Supply sends out two separate signals: ACFAIL and RESET.  ACFAIL -> XIRQ, RESET from power supply -> RESET pin (MCU).
 
When MCU receives RESET in LOW, it will not restart until RESET in High. Is this correct? if it is true, what I want to do, in XIRQ ISR, how can I ignore this EXTERNAL RESET signal so that it won't generate internal reset (SYSTEM RESET) since XIRQ has 25ms to prevent INTERNAL RESET from triggering.
 
I would like to say in XIRQ:
 
COPCTL = 0x01;
ARMCOP = 0x55;
ARMCOP = 0xAA; // start COP
 
As here, I need to know to prevent Internal RESET from triggering. (need your help)
 
Then I need to watch EXTERNAL RESET signal from Power Supply. Is there a way to watch this pin?
 
If it is high less than two seconds, I will disable COP, otherwise, I will let it go --- restart from COP reset
 
My understanding may be wrong. Thanks for corrections.
 
Pang
0 Kudos

821 Views
Alban
Senior Contributor II
Pang,

Pang wrote:
 
When MCU receives RESET in LOW, it will not restart until RESET in High. Is this correct?

 
True
 


Pang wrote:
it is true, what I want to do, in XIRQ ISR, how can I ignore this EXTERNAL RESET signal so that it won't generate internal reset (SYSTEM RESET) since XIRQ has 25ms to prevent INTERNAL RESET from triggering.
 
I would like to say in XIRQ:
 
COPCTL = 0x01;
ARMCOP = 0x55;
ARMCOP = 0xAA; // start COP
 
As here, I need to know to prevent Internal RESET from triggering. (need your help)
 
Then I need to watch EXTERNAL RESET signal from Power Supply. Is there a way to watch this pin?
 
If it is high less than two seconds, I will disable COP, otherwise, I will let it go --- restart from COP reset

 
What the power supply calls a reset is just a normal signal for the MCU. There will not be an MCU internal reset if you link the power supply signal to the IRQ, XIRQ or Timer.
By using an Input Capture, you can watch the lenght of the external signal.
Then, if the lenght is higher than 2 seconds, you can take whatever action you want, like resetting the MCU.
 
Alban.

0 Kudos

821 Views
Pang
Contributor I
Alan,
 
Could you show me how to use input Capture in this MCU?
 
According to what you told, what if EXTERN RESET from power supply is directly connect to RESET MCU pin? Does this mean that there is no way to control INTERNAL RESET caused by this EXTERNAL RESET?
 
I hope I am wrong.
 
Regards,
 
Pang
0 Kudos

821 Views
Alban
Senior Contributor II
Sorry Pang,
 
For code, you will have to refer to the Application Notes available for the S12X.
 
Yes, if a low level is applied on the RESET pin of the microcontroller, it goes immediately into reset. This is not negociable nor can be changed. This is internally hard coded.
 
Alban. {in bed now}
0 Kudos

821 Views
YeOldeBDM
Contributor III
This is not directly related to the OP's question, but  it can save you a lot of trouble when dealing with asynchronous power failures-
 
Rewrite the start-up code to initialize the wdt and do the i/o mapping right where the reset vector(s) point(s) to. Don't leave any window of code execution for an uninitialized WDT if the supply can go out of spec in this window.
 
0 Kudos

821 Views
Pang
Contributor I
Hi YeoldeBDM,
 
I am not qute sure to understand your idea. Do you have an example and show me how to deal with short term power surge in Start-up code?
 
Thanks a lot, my friend.
 
Pang
0 Kudos

821 Views
wilero17
Contributor I

I was sawing some tips in the forum about the watchdog timer and I have some questions.

 

actually
I'm working with the HCS12 microcontroller and I need to use the
watchdog timer in order to do  reset. I've configurated the COPCTL
register with 71 (COPCTL=71) the program
stay in a infinite for loop showing a caracter ascii in the
hyperterminal until the watchdog finish. The problem is:  after the
watchdog timer has finished the program doesn't reset o may be yes, but
I can't see more caracters in the hyperterminal until I do a manual
reset.  I've attached the program. I hope that you can help me. many
thanks.


 

 

This is the main function:



 void main(void) {
  /* put your own code here */

  char msn[20]={"Hola"};
  char msn1[5]={"."}; 
  word cont1X;
  word cont2X;

  cont2X=0;
  while(cont2X<=5000)
  {
    cont2X++;
    cont1X=0;
    while(cont1X<=100)
    {
      asm BRN *;
      cont1X++;    
    }    
  }

  SCI0BD = 12;

  SCI0CR1 = 0x00;

  SCI0CR2 = 0x04;

  vfnSCITxMsg(msn);
  COPCTL=71;
  
  for(;;) {
  cont2X=0;
  while(cont2X<=5000)
  {
    cont2X++;
    cont1X=0;
    while(cont1X<=100)
    {
      asm BRN *;
      cont1X++;    
    }    
  }
  vfnSCITxMsg(msn1);
  } /* loop forever */
  /* please make sure that you never leave main */
}
0 Kudos