View previous topic :: View next topic |
Author |
Message |
Guest
|
reset_cpu() in int_rda service routine |
Posted: Wed Mar 01, 2006 4:14 pm |
|
|
I thought PIC16F628A has a MCLR instruction set . . . well, it does not, but can I call reset_cpu() in RDA servicie routine?
I know stack will be left intact and possibly a harzard, but as PCM Programmer pointed in various thread, the stack is circular, so no problem . . . but are there any other issues?
Thanks in advance. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Re: reset_cpu() in int_rda service routine |
Posted: Wed Mar 01, 2006 4:29 pm |
|
|
Anonymous wrote: | but can I call reset_cpu() in RDA servicie routine?
|
I'm not a big fan of microcontroller suicides, so I'm just guessing and I have never tried this myself. You could set up and strobe a watchdog timer (WDT, if your PIC has one). In the ISR you would make a long delay without strobing the WDT. WDT would reset the PIC. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 01, 2006 4:33 pm |
|
|
I am wondering if you really have to structure your program in this way ?
Why do you believe that you have to re-start program execution from
the reset vector (address 0x0000) if you receive a 0xFF byte ?
Why not just instead, perhaps go to the start of a while() loop ? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Mar 01, 2006 4:36 pm |
|
|
Quote: |
it does not, but can I call reset_cpu() in RDA servicie routine?
|
I would like to know the reason to do that.
I am convinced that it must have several elegant and much safe solutions.
Humberto |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Mar 01, 2006 5:33 pm |
|
|
I have done this previously. I did have one verison of the PCH compiler that had a bug (not sure of the versions 3.229?) that required two reset_cpu() instructions one after the other to work. My code was inside a case statement and the time and the compiler incorrectly branched past the first instruction. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Wed Mar 01, 2006 8:02 pm |
|
|
Kender, that is so funny.
Well, WDT works fine but a long delay? in milliseconds? No, I'd rather commit suicide :-) |
|
|
Guest
|
|
Posted: Wed Mar 01, 2006 8:06 pm |
|
|
PCM programmer, well, I want my core code to execute without any interrupts when delay_xx() is called but want to break that tight loop, so a reset_cpu() or MCLR would be fine.
As you said, maybe I should invest some time to do my own delay routines, I did it using another compiler that does not have a lot of builtin functions but failed at accuracy. So I bought this compiler . . . |
|
|
Guest
|
|
Posted: Wed Mar 01, 2006 10:25 pm |
|
|
Humberto, the reason is, I am too lazy to figure out my own PRECISE delay function. |
|
|
Guest
|
|
Posted: Wed Mar 01, 2006 10:25 pm |
|
|
asmallri, thanx. |
|
|
|