Searching \ for 'PIC12C508JW sleep mode' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PIC12C508JW sleep mode'.

Truncated match.
PICList Thread
'PIC12C508JW sleep mode'
1999\06\14@093536 by Andrew Russell Morris

flavicon
face
Dear PIC'ers;

I recently started using the '508 and I'm having problems with the sleep
mode. The program runs fine one time, but will not run after the chip goes
to sleep and (presumably) wakes up. Below is part of my code. What am I
doing wrong, or is there some problem or quirk with the '508, that I don't
know about? The code works fine if I just go to STRT and don't use the
sleep mode, but I don't get the battery power savings that the sleep mode
offers, which I need. I'm sure you understand that I can't publish the body
of the code, since it belongs to my employer.

Any help would be greatly appreciated.  TIA  Andrew Morris  :-)



;---------------------------------------------------------------------------
---------------

;      At blast time:
;      MCLRE = EXT
;      CP = OFF
;      WDT = ON
;      FOSC = INT

;---------------------------------------------------------------------------
---------------

      include c:\progra~1\mplab\P12c508.inc

      MOVWF     OSCCAL
      BTFSS     STATUS,3           ;Was reset due to sleep? Skip next line
if not
      GOTO      STRT

;      Initialize I/O ports

      MOVLW     INI_GPIO          ;Initialize io port
      MOVWF     GPIO
      MOVLW     CFG_GPIO          ;Select direction of GPIO bits
      TRIS      GPIO              ;Write selection to TRIS data direction
register
      CLRF      TMR0
      CLRWDT
      MOVLW     INI_WDT
      OPTION

STRT   BCF       GPIO,PD_EN_N      ;first lIne of code
.
.
.
body of code
.
.
.
SLEEP

END

1999\06\14@133545 by William K. Borsum

flavicon
face
At 09:34 AM 6/14/99 -0400, you wrote:
>Dear PIC'ers;
>
>I recently started using the '508 and I'm having problems with the sleep
>mode. The program runs fine one time, but will not run after the chip goes
>to sleep and (presumably) wakes up. Below is part of my code. What am I
>doing wrong, or is there some problem or quirk with the '508, that I don't
>know about? The code works fine if I just go to STRT and don't use the
>sleep mode, but I don't get the battery power savings that the sleep mode
>offers, which I need. I'm sure you understand that I can't publish the body
>of the code, since it belongs to my employer.

Is your clock restarting the way you think it should?  Not usually a
problem with high frequency clocks, but definitely can get strange with
watch crystals.
Kelly

****************************************************************************
********
All legitimate attachments to this email will be clearly identified in the
text.
William K. Borsum, P.E.
OEM Dataloggers and Instrumentation Systems
<spam_OUTborsumTakeThisOuTspamdascor.com> & <http://www.dascor.com>

1999\06\14@192554 by Tony Nixon

flavicon
picon face
Andrew Russell Morris wrote:
>
> STRT   BCF       GPIO,PD_EN_N      ;first lIne of code
> .
> .
> .
> body of code
> .
> .
> .
> SLEEP
>
> END

What code comes after SLEEP. Don't forget that your code will continue
from there, not at address 0000h.


--
Best regards

Tony

'The Engine' - Design your own programmer.

http://www.picnpoke.com
Email .....picnpokeKILLspamspam@spam@cdi.com.au

1999\06\15@152740 by Andrew Russell Morris

flavicon
face
At 09:24 AM 6/15/99 +1000, you wrote:
>Andrew Russell Morris wrote:
>>
>> STRT   BCF       GPIO,PD_EN_N      ;first lIne of code
>> .
>> .
>> .
>> body of code
>> .
>> .
>> .
>> SLEEP
>>
>> END
>
>What code comes after SLEEP. Don't forget that your code will continue
>from there, not at address 0000h.
>

Nothing. This chip doesn't prefetch the next command after sleep like the
PIC16C84, for example does. The datasheet tells you to look at the status
bits to determine the cause of reset. I also had to do this on the 16C55,
and it works fine. I must've forgotten to print it, but before the STRT
line, I have the following code:
      BTFSS     STATUS,3           ;Was reset due to sleep? Skip next line
if not
      GOTO      STRT
      MOVWF     OSCCAL

;      Initialize I/O ports

      MOVLW     INI_GPIO          ;Initialize io port
      MOVWF     GPIO
      MOVLW     CFG_GPIO          ;Select direction of GPIO bits
      TRIS      GPIO              ;Write selection to TRIS data direction
register
      CLRF      TMR0
      CLRWDT
      MOVLW     INI_WDT
      OPTION

This is to determine the cause of reset, calibrate the oscillator and
initialize and configure the I/O port.

Thanks for your response and TIA for your help.

1999\06\15@193413 by Tony Nixon

flavicon
picon face
Andrew Russell Morris wrote:
> Nothing. This chip doesn't prefetch the next command after sleep like the
> PIC16C84, for example does.

Just goes to show, just when you thought you knew it all, you learn that
you don't :-)

I gather the chip is woken up because of the WDT.

I notice you have a CLRWDT in the reset part of your code, which also
resets the PD bit back to 1 again. Are you using this instruction in the
main body of your code?

{Quote hidden}

--
Best regards

Tony

'The Engine' - Design your own programmer.

http://www.picnpoke.com
Email picnpokespamKILLspamcdi.com.au

1999\06\15@232551 by J Nagy

flavicon
face
Andrew Russell Morris  wrote:
>
>I recently started using the '508 and I'm having problems with the sleep
>mode. The program runs fine one time, but will not run after the chip goes
<snip>
{Quote hidden}

       It looks like you're using the watchdog timer to wake up the chip.
If this is so, STATUS,3 will be set by the WDT (see status register
description). You may also want to look at bit 4 to see if the WDT did time
out.


       Jim Nagy
       Elm Electronics
 ICs for Experimenters
http://www.elmelectronics.com/

1999\06\16@141534 by Andrew Russell Morris

flavicon
face
Thanks for your response. Table 8-7 of the data sheet for this chip says
that both the PD and TO status bits will be low after the chip is awakened
by the WDT. Besides, that can't be my problem, anyway. The chip would just
go through initialization every time ti wakes up, but still work. My
program just runs once and goes into a hi-z state like it was held in
reset. I even changed the port initialization to ensure that the MCLR pin
is an input, preset high. No effect. It doesn't matter, anyway, according
to the data sheet.  Any more ideas? TIA for all help.

{Quote hidden}

1999\06\17@082747 by g.daniel.invent.design

flavicon
face
Hi Andrew,
#1      make sure that your JW version part is *fully* erased, some config
register bits (mclr configuration ?) may be at an unintended level.

#2      don't set code protect on the JW versions, unless you are rich.

#3      find below some excerpts from my *working code* using watchdog with
pic12C508,  essentially program toggles on/off status for each pulse of
MCLR, in ON mode it pulses leds briefly, makes some sounds and then goes
into standby, watchdog wakes it up again after predetermined time. In
off mode the watchdog period is doubled from that of initialisation and
each watchdog reset sends it back into "noddy land" so that most time is
spent in low power mode. connect a piezo between "piezo1" & "piezo" if
you want to fiddle with it, mak sure you get a good erase time between
programming also !

watchdog is in config and so cannot be shut down for a standby mode by
S/W.
regards,
Graham.


;       BY GRAHAM DANIEL 9 RUA ST LYALL BAY BEGINNING PROJECT 25/4/98.
;
;       ALL SOFTWARE BY GRAHAM D.

       LIST    P=12C508 ; PIC12C508 IS THE TARGET PROCESSOR

       #INCLUDE        <P12C508.INC>

;       __CONFIG        _CP_ON & _WDT_ON & _IntRC_OSC & _MCLRE_ON ; OTP only !
       __CONFIG        _CP_OFF & _WDT_ON & _IntRC_OSC & _MCLRE_ON ; "jw" part o
nly !

MV1     EQU     0
MV2     EQU     0
MV3     EQU     0


RAMBASE         EQU     H'07'
   CBLOCK      RAMBASE

       TASK_FLAGS,SYNC_LOCATION,TIME_OUT

       COUNT,TEMP

       DEL_1,DEL_A

       CNTR_1,PERIOD,TONE,DUR

   ENDC

#DEFINE _ON_OFF                 TASK_FLAGS,0


#DEFINE _GREEN                  GPIO,0
#DEFINE _RED                    GPIO,1
#DEFINE _BLUE                   GPIO,2
#DEFINE _PIEZO1                 GPIO,4
#DEFINE _PIEZO2                 GPIO,5

;---------------------------------------------------------------------------

;M A C R O    D E F I N I T I O N S :     BY GRAHAM DANIEL:
WMOVL   MACRO   MV1,MV2     ; MOVE [LITERAL] INTO [FILE]   2 CYCLES
       MOVLW   MV1
       MOVWF   MV2
       ENDM

WMOVF   MACRO   MV1,MV2     ; MOVE [FILE] TO [FILE]        2 CYCLES
       MOVF    MV1,W
       MOVWF   MV2
       ENDM

BTG     MACRO   MV1,MV2         ; toggle bit of file reg/port
       MOVLW   1 << MV2
       XORWF   MV1,F
       ENDM

;WMOVL WMOVF BTG

PULSE   MACRO   MV1,MV2,MV3,MV4 ; PORT,PIN,ON,OFF
       BSF     MV1,MV2

       MOVLW   MV3
       CALL    DELOOP_1

       BCF     MV1,MV2

       MOVLW   MV4
       CALL    DELOOP_1
       ENDM

NPULSE  MACRO   MV1,MV2         ; PERIOD,DURATION
       WMOVL   MV1,PERIOD
       WMOVL   MV2,DUR
       CALL    TW_BD_LOOP
       ENDM

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------

       ORG   0x0000

       MOVWF   OSCCAL

       MOVLW   B'11011110'
       OPTION

       MOVLW   B'11001000'
       TRIS    GPIO                    ; DIRECTION LATCH.
       WMOVL   B'00101000',GPIO        ; SET ALL INACTIVE


       MOVLW   B'11110000'
       ANDWF   STATUS,W
       BZ      START
RESTART
       BTG     _ON_OFF
       BTFSS   _ON_OFF
       GOTO    OFF_MODE
ON_MODE
       WMOVL   7,CNTR_1
SHOW_ON
       NPULSE  D'20',D'255'
       PULSE   _BLUE,D'8',D'10'
       PULSE   _RED,D'8',D'10'
       PULSE   _GREEN,D'8',D'10'
       DECFSZ  CNTR_1

       GOTO    SHOW_ON

       WMOVL   B'00000011',SYNC_LOCATION

       GOTO    START

OFF_MODE
       MOVLW   B'11011111'
       OPTION

       SLEEP

;===========================================================================

START
       BTFSS   _ON_OFF
       GOTO    OFF_MODE

       INCF    SYNC_LOCATION,W
       ANDLW   B'00000011'
       MOVWF   SYNC_LOCATION
       ADDWF   PCL
       GOTO    PHASE1
       GOTO    PHASE2
       GOTO    PHASE3
       GOTO    PHASE4

;===========================================================================

PHASE1
       PULSE   _GREEN,D'30',D'1'
       NPULSE  D'8',D'255'
       NPULSE  D'8',D'255'
       NPULSE  D'8',D'255'
       NPULSE  D'8',D'255'
       PULSE   _GREEN,D'30',D'1'

       SLEEP

PHASE2
       PULSE   _RED,D'30',D'1'
       NPULSE  D'16',D'255'
       NPULSE  D'16',D'255'
       PULSE   _RED,D'30',D'1'

       SLEEP

PHASE3  CALL    SEQ3
       SLEEP

PHASE4  CALL    SEQ4
       SLEEP


SEQ3
       PULSE   _BLUE,D'30',D'1'
       NPULSE  D'32',D'128'
       NPULSE  D'32',D'128'
       PULSE   _BLUE,D'30',D'1'
       RETURN


SEQ4    PULSE   _GREEN,D'30',D'20'
       NPULSE  D'64',D'255'

       PULSE   _RED,D'30',D'20'
       NPULSE  D'126',D'255'

       PULSE   _BLUE,D'30',D'20'
       NPULSE  D'255',D'255'
       RETURN



       GOTO    START           ; ALL COMPLETED !

;===========================================================================



;===========================================================================

DELOOP_1
       MOVWF   DEL_1
RELOOP_1
       GOTO    DELOOP_2
RE_ENTER_RELOOP_1
       DECFSZ  DEL_1,F
       GOTO    RELOOP_1
       RETURN

DELOOP_2
       MOVWF   COUNT
DELOOP_3
       CLRWDT
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       DECF    COUNT,F
       BTFSS   STATUS,Z        ;SKIP IF DEC'ED TO 0 & Z FLAG SET
       GOTO    DELOOP_3
       GOTO    RE_ENTER_RELOOP_1

;===========================================================================

TW_BD_LOOP
       WMOVF   PERIOD,DEL_1
WASTE_TIME
       CLRWDT
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       NOP
       DECFSZ  DEL_1,F
       GOTO    WASTE_TIME
       BTG     _PIEZO2
       DECFSZ  DUR,F
       GOTO    TW_BD_LOOP
       RETURN

;===========================================================================

       END




--
Steam engines may be out of fashion, but when you consider that an
internal combustion engine would require recovery of waste heat by
transfer just before top dead centre then fashion becomes rather
redundant, USE STRATIFIED HEAT EXCHANGERS ! and external combustion.

You heard it first from: Graham Daniel, managing director of Electronic
Product Enhancements.
Phone NZ 04 387 4347, Fax NZ 04 3874348, Cellular NZ 021 954 196.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...