PDA

View Full Version : 12c508 @sleep command?



rtsandiego
- 12th January 2004, 03:16
I was wondering if it is possible to use the assembly command "@sleep" to have a 12c508a chip stop execution and then start again where it left off after sensing an input level change.

I am worried that it will reset execution at the start of the program.

Melanie
- 12th January 2004, 07:51
It'll work just fine, but WDT must be OFF otherwise it'll reboot the PIC.

rtsandiego
- 12th January 2004, 15:57
Thanks for the tip on WDT. I'll give it a try today.

It's amazing what can be accomplished by using PIC's.

Bruce
- 13th January 2004, 05:44
The 12C508A series can only wake-up from SLEEP with a device reset like /MCLR, WDT timeout, or wake-up on pin change.

The catch is - that even wake-up on pin change with the 12C508A causes a device reset, and you're starting over again from square #1 after any wake-up event.

The good news is - the 12C67x series can wake up from SLEEP & then continue execution at the instruction immediately after the SLEEP instruction if you have global interrupts disabled (GIE=0).

With global interrupts enabled (GIE=1), the 12C67x will wake-up, then execute the instruction after the SLEEP instruction, then branch to the interrupt vector at location 0004h assuming you have an interrupt handler in place.

rtsandiego
- 13th January 2004, 06:56
So on the '508 series it always reboots regardless of the enable WDT settings?

Bummer. The '508 series are typically the most inexpensive PIC's.

Melanie
- 13th January 2004, 09:01
> Bummer.

Not quite... all you have to do at the start of your program is check the GPWUF bit in the STATUS register

eg...

If STATUS.7=1 then goto WakeFromSleep

See Datasheet section 8.7 and section 4.3. I keep saying to everyone, you gotta read those Datasheets - or if like me, reading Datasheets isn't your thing on cold winter nights, then at least get to know where things are found so you can jump straight to it - all Microchips Datasheets follow the same layout.

PS. If you want to play with little PIC's then 12F675 is the way to go... they're almost the price of the 12C508/9 and still dropping.

Melanie

Bruce
- 13th January 2004, 14:25
Yep - you're still in charge if you know where to look...;o]

I agree with Melanie. If you want the best bang-for-the-buck, then go with the 12F675 or 12F629. They have a few more features, are re-programmable, and only a few pennies more than the 508 series.

rtsandiego
- 14th January 2004, 06:59
Took a look at the 12F629. Goodbye '508, Hello Flash memory!

Thanks Melanie and Bruce for your good advice.