Hi i use SW reset command in my code. after reset, PC is set to address 0x0000. unfortunately at this address i can't find nor main{} neither JMP to main. which are the tools i can use (startup.a51 or others) in order to direct the program on address 0x0000 to main{}?
i use SW reset command in my code.
That's a very common idea, and just as commonly a really bad one.
If you need a reset, do yourself a favour and perform the real one, not some cheap knock-off. Jumping to start-of-code is not a reset; it often doesn't even come usefully close.
The state of just about everything will be different from what it is when the hardware comes up out of an actual, proper HW reset. You'll likely spend more on finding and cleaning up all those differences than you would on just getting a proper reset to be executed. Traditionally one just lets the watchdog starve on purpose. If you don't have a watchdog, maybe you let this be the lesson that teaches why that's a bad idea.
Thank you Eric and Hans-Bernhard for your replies I continued on with my investigation and the issue is a bit more complicated. Both of you indeed directed to my findings. i use a watchdog, but a tailored one. by reaching the time limit of the watchdog (PCA ISR) i use the watchdog ISR to save RAM data to the FLASH memory and invoke the SW reset. from inside the watchdog ISR i call to save to FLASH memory function (which calls some other functions). when i call this function, for some reason, the SW reset brings the PC to address 0x0003. if i omit the call to save to FLASH memory function the SW reset is done properly and brings the PC to address 0x0000. i assume this is due to the fact i use different register banks in the function (and the other functions it calls) and in the ISR. although i'm not sure why this should afect the SW reset i'll try to turn memory save function to be "reentrent". Hans-Bernhard, you mentioned something about differences between SW reset and HW reset. do you have some tips on that? thanks M.
WHICH CHIP?
SILAB C8051F931
View all questions in Keil forum