Hi,
i want to reset my mircocontroller by software. After the reset the controller should start at Startup and do everything from the beginning (start at reset vector, load variables with initial values, load the main() function, etc.). I've read that i can do this f.e. through ILOP Code, so i try it with this:
asm bgnd; //Reset
When the program enters this instruction, my hardware obvoisly resets (leds in my ciruit turn shortly off) but the code continues after the reset at the next line next to the reset command, and doesn't begin from startup?! In the controllers datasheet i find: "During reset, most control and status registers are forced to initial values and the program counter is loaded from the reset vector (0xFFFE:0xFFFF)." But the program counter holds it old value. Also the RAM variables hold their old values.
How can i reset correctly?
I also try "asm jmp _Startup;" and it works... but i doesn't really know what happens with the old values in stack and stack pointer?
I am working with CodeWarrior 5.9.0, with Device Initialization, C-Code
Solved! Go to Solution.
bgnd is legal instruction when you are debugging code using BDM over BKGD pin. It just makes your target stopped and awaiting for BDM instructions. It should work as reset when booted with no BDM connected.
Hello,
you can search the Forum for ILOP or ILAD. There you will find Solutions for a Softwre Reset..
One Example is here : https://community.freescale.com/message/23967#23967
Eckhard
Hi Eckard,
thank you for answering, but it's not the solution. I've allready try these software resets like in that Link which you offer. And my controller also do something like a reset (LEDs are blinking) when i call this assembler instructions. But the problem is that my controller doesn't start from the beginning at the position of startup code when i debug. Or is the debugger not able to show me the right result?
When i am entering the codeposition with the software reset instruction in debug mode (Real Time Debugger from CodeWarrior), the debugger stops. When i press the "single step" button at this point, i expect that my Program Counter jumps to the Startup Code Position, but it doesn't. It jumps to the instruction next to software reset instruction.
bgnd is legal instruction when you are debugging code using BDM over BKGD pin. It just makes your target stopped and awaiting for BDM instructions. It should work as reset when booted with no BDM connected.
Sounds logical. So i only can't debug it in the right way. I will try with an other ILOP instruction.
Thanks