HCS08: There is no "reset" instruction?

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

HCS08: There is no "reset" instruction?

6,509 Views
BasePointer
Contributor II
Hi,
 
I want to reset the MCU at some conditions.
But there is no instruction to do this with HCS08.
How can I reset the MCU without using COP?
 
MCU is MC9S08LC60.
 
Thank you.
Labels (1)
0 Kudos
Reply
12 Replies

1,831 Views
Nouchi
Senior Contributor II
Hello,

You can generate RESET by doing illegal operation, you can find an example in AN2295

Code:
ILOP        MACRO            DC.B    $8d             ; this is illegal operation code            ENDM

 call this macro and processor will reset with illegal opcode (you can see that in SRS register and ILOP flag)

Emmanuel

0 Kudos
Reply

1,831 Views
BasePointer
Contributor II
Hi BugMan,
 
How can I use this in C?
Code:
if(++SOFTWARE_WATCHDOG > 200) asm("DC.B $8d");Error: C18125: Invalid opcode or ':' expected

 Thanks.
0 Kudos
Reply

1,831 Views
Alban
Senior Contributor II
 
Code:
if(++SOFTWARE_WATCHDOG > 200)    {                       /* Generate a RESET by Illegal Opcode */   asm DCB 0x8D ;   }

 
 
This does work.
 
Alban.
0 Kudos
Reply

1,831 Views
BasePointer
Contributor II
Hi Alban,
 
asm("jmp 0x00"); -> doesn't generate illegal opcode reset for me. The application crashs with it.
 
But this worked as I expected.
if(++SOFTWARE_WATCHDOG > 200) asm("DCB 0x8D");
 
Thank you so much.
0 Kudos
Reply

1,831 Views
Alban
Senior Contributor II
Thanks for the feedback BP, may be the S08 doesn't behave as I thought.
I find it abnormal though.
 
Manu/Peg ?
Any experience on this ILAD ?
 
I will Read The Factory Manual and see...
 
Alban.
0 Kudos
Reply

1,831 Views
Alban
Senior Contributor II
Everything is OK.
 
The confidential product you are talking about does not feature ILAD.
Same for GB60.
 
Alban.
0 Kudos
Reply

1,831 Views
peg
Senior Contributor IV
Ahhh!
So this is what Rocky meant by "there are no illegal addresses on a GB60" in my "QG BKGD issues" thread!
All newer A version 'less than 60' GB/GT's have it re-instated.
 
0 Kudos
Reply

1,831 Views
Nouchi
Senior Contributor II
Hi,


The first solution comes to my mind, is to write a pure asm function (not in lined), and call the function in your C file. The Inline assembler seems to be quite strict.


Emmanuel
0 Kudos
Reply

1,831 Views
peg
Senior Contributor IV
Hi,
 
Take a look here:
 
 
for some other ideas on this.
 
0 Kudos
Reply

1,831 Views
Alban
Senior Contributor II
Hello,
 
BugMan's method is also my prefered.
You can also generate an ILAD (Execute from Illegal Address), by doing
 
          JMP 0x00;
 
0x00 is not a code region but registers.
 
I prefer ILOP as an ILAD is more likely to happen in code runaway situations.
Therefore I prefer my software to know when a real ILAD occured.
 
Cheers,
Alban.
0 Kudos
Reply

1,831 Views
BasePointer
Contributor II
Hi Alban,
 
Code:
if(++SOFTWARE_WATCHDOG > 200) asm("JMP 0x00");

 
This is compiled succesfully. But I wonder is this real reset or just jump to 0?
Can I re-initialize one-time writeable registers after this reset?
Will all registers set back to their reset values?
 
Thank you.
0 Kudos
Reply

1,831 Views
Alban
Senior Contributor II
Hi,
 
0x00 cannot be executed from as the MCU knows it is a register area.
Therefore a jump to 0 will trigger an Illegal Address Reset (ILAD Flagged).
 
All registers go to their reset value, and write-once are released like if it was a PIN Reset.
 
Cheers,
Alban.
0 Kudos
Reply