Dear All:
i'm now using the 9s08dz32. i want to generate an illigal operation to force the mcu to reset. when in asm, the code looks like this:
ILOP MACRO ;
DC.B $8d ; this is illegal operation code
ENDM ;
but i don't know how to implement this code into C.
could anyone help me?
Hello,
I am not sure whether this can be done with inline assembly?
However, a method that should work would be to create an ASM file to contain the illegal operation code within a sub-routine. The sub-routine would then be called from within the C file (as a function with the same name). A prototype will be needed within the C file, and an XDEF reference within the ASM file.
Perhaps others will be able to provide a simpler method.
Regards,
Mac
could you please explain it in detail, or where can i find the instructions on how to call a sub-routine which is in assembly in C?
sorry for my cross post
Hello,
Fabio Pereira has an example for an ILAD reset on his page.
Look at the Code for chapter 5.
It should be easy to adapt it to ILOP.
The reset function is implemented als follows :
void reset(void)
{
unsigned int temp = 0x9E00;
__asm
{
LDHX @temp // load the address of temp into H:X
JMP ,X // jump to the address pointer to by H:X
}
}
Eckhard
Hello,
Maybe the following might work for an ILOP reset.
void reset(void)
{
byte temp = 0x8D;
__asm JMP @temp; // Jump to the illegal opcode
}
Regards,
Mac
As it was discussed in the past, there is no need for the jmp.
https://community.freescale.com/message/10910#10910
The HLI supports to embed arbitrary bytes into the instruction stream.
Daniel
I have used:
#define MCU_RESET() asm DCW $9E00
.
.
.
if (Result[Ch]>=24)
MCU_RESET();
Hello,
I think this has been covered before. Search this forum. Maybe include ILOP in search.
It has definately been discussed before but I am not sure on the 'C' details.
Worth a try anyway.