Software Reset

Started by tadaosystems May 20, 2005
Is it possible to do a software reset without using mclr or the
watchdog timer on a PIC16F87 or 88?

Would a long jump to 0000h work (besides the obvious fact that no
registers or variables would be reset)? In HT PICC I've been trying
to use

asm("ljmp 0000h");

to no avail. What's the best way to jump to absolute addresses?


--- In piclist@picl..., "tadaosystems" <flipflops67@h...>
wrote:
> Is it possible to do a software reset without using mclr or the
> watchdog timer on a PIC16F87 or 88?
>
> Would a long jump to 0000h work (besides the obvious fact that no
> registers or variables would be reset)? In HT PICC I've been
trying
> to use
>
> asm("ljmp 0000h");
>
> to no avail. What's the best way to jump to absolute addresses?

Here is another way using function pointers:

#define PROG_START 0x0000

( *( (void(*)(void))PROG_START ) )(); //goto ORG



Doesn't that use up one level of the stack, though? I assumed that
if you simply jumped to the reset vector it wouldn't set a return
point, whereas using the void void was more like HT PICC's "fcall".

In any case, it didn't work for me, either. --- In piclist@picl..., "john" <j_funk1425@y...> wrote:
> --- In piclist@picl..., "tadaosystems" <flipflops67@h...>
> wrote:
> > Is it possible to do a software reset without using mclr or the
> > watchdog timer on a PIC16F87 or 88?
> >
> > Would a long jump to 0000h work (besides the obvious fact that
no
> > registers or variables would be reset)? In HT PICC I've been
> trying
> > to use
> >
> > asm("ljmp 0000h");
> >
> > to no avail. What's the best way to jump to absolute addresses?
>
> Here is another way using function pointers:
>
> #define PROG_START 0x0000
>
> ( *( (void(*)(void))PROG_START ) )(); //goto ORG


> Doesn't that use up one level of the stack, though?

The 12/14 bit core stack is infinite as far as pushing something onto it
is concerned. It is only when you try to pop from it that you will be
aware of the limited stack depth.

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu


I'm able to get both asm("ljmp 0000h") and the function pointer to
work (atleast with compiling for PIC16F876 and using the simulator).

asm("ljmp 0000h") compiles to:
BCF 0xa, 0x4 ;<--PCLATH
BCF 0xa, 0x3
GOTO 0

function pointer compiles to:
BCF 0xa, 0x4
BCF 0xa, 0x3
CALL 0 --- In piclist@picl..., "tadaosystems" <flipflops67@h...>
wrote:
> Doesn't that use up one level of the stack, though? I assumed
that
> if you simply jumped to the reset vector it wouldn't set a return
> point, whereas using the void void was more like HT PICC's "fcall".
>
> In any case, it didn't work for me, either. > --- In piclist@picl..., "john" <j_funk1425@y...> wrote:
> > --- In piclist@picl..., "tadaosystems"
<flipflops67@h...>
> > wrote:
> > > Is it possible to do a software reset without using mclr or
the
> > > watchdog timer on a PIC16F87 or 88?
> > >
> > > Would a long jump to 0000h work (besides the obvious fact that
> no
> > > registers or variables would be reset)? In HT PICC I've been
> > trying
> > > to use
> > >
> > > asm("ljmp 0000h");
> > >
> > > to no avail. What's the best way to jump to absolute
addresses?
> >
> > Here is another way using function pointers:
> >
> > #define PROG_START 0x0000
> >
> > ( *( (void(*)(void))PROG_START ) )(); //goto ORG