Settimer messing Hibernate ?

pjrebordao

Senior Member
Maybe Technical can shed some light on this:

- Can the use of Settimer in some way prevent an 28x1 from waking up after a Hibernate 1 command ?
- I have a circuit involving a switch tied into ADC0. Pressing the switch usually wakes up the PIC after a Hibernate command, as intended. However, after using any variant of the settimer command, pressing the switch makes no efect. Only a hard reset will do.
- The code is a bit more complex than this, but I'm confident that I isolated settimer as the culprit...
 

Technical

Technical Support
Staff member
Not that we are aware of. The hibernate command actually switches off the timer interrupt (PIE1,TMR1IE) as part of its code anyway. However it could possibly be a feature of the way the base PIC microcontroller works.

Have you tried a 'settimer off' before the hibernate command in your program? If there was a silicon TIMER1 issue this would prove it either way, as 'off' puts the chip back into normal state.
 

pjrebordao

Senior Member
I've tried settimer off with the same results.
Your can try the following piece of code and check it for yourselves:

low 1
setfreq m4

main:
hibernate 1
high 1
pause 1000
low 1
settimer off
goto main
end

Try commenting out the settimer line and check the difference it makes.

It would be useful if you could come up with some sort of workaround...
 

pjrebordao

Senior Member
I might be getting ahead of myself, but I think this could be related to bit GIE in register INTCON not being properly cleared.

I inserted this bit of code:

settimer off
peek B0INTCON, INTCON ' clear GIE flag in bank0 INTCON
let INTCON = INTCON & GIECLR
poke B0INTCON, INTCON

peek B1INTCON, INTCON ' clear GIE flag in bank1 INTCON
let INTCON = INTCON & GIECLR
poke B1INTCON, INTCON

and, now hibernate 1 works after settimer !
 

Technical

Technical Support
Staff member
Thanks for the info, but we think the issue is more subtle than this as the firmware already clears INTCON GIE. Incidentally INTCON is actually only one register but is 'mirrored' on all banks, so you only need to poke it once.

Have you tried this

settimer off
pause 1
hibernate 1
 

pjrebordao

Senior Member
Tried inserting pause after settimer off, but there's no change. It still doesn't wakeup...
Thanks for the "mirroring" information.
 
Top