Searching \ for 'Wake and Sleep code for 84 device' 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/index.htm?key=wake+sleep+code
Search entire site for: 'Wake and Sleep code for 84 device'.

Truncated match.
PICList Thread
'Wake and Sleep code for 84 device'
1995\11\27@091011 by Mike Barrett

flavicon
face
Has anyone got any simple code that I can 'borrow' to make a '84 wake up
from sleep mode when an input changes state? I also want some code to put
the device back into sleep mode.

The application? Well I want to build my daughter an electronic gadget  for
christmas. Press a button and lights come on, the thing beeps and then
switches off !

Any help much appreciated!

Mike Barrett
=============================================
Mike Barrett                E-mail: spam_OUTbarrettTakeThisOuTspamcambridge.scr.slb.com
Schlumberger Cambridge Research      Phone: 01223 325200
PO Box 153, Cambridge, CB3 OHG. U.K    Fax: 01223 327019
=============================================

1995\11\27@115411 by Mike Barrett

flavicon
face
(Sending again as the first attempt seemed to have been rejected by the
listserver)

Has anyone got any simple code that I can 'borrow' to make a '84 wake up
from sleep mode when an input changes state? I also want some code to put
the device back into sleep mode.

The application? Well I want to build my daughter an electronic gadget  for
christmas. Press a button and lights come on, the thing beeps and then
switches off !

Any help much appreciated!

Mike Barrett
=============================================
Mike Barrett                E-mail: .....barrettKILLspamspam@spam@cambridge.scr.slb.com
Schlumberger Cambridge Research      Phone: 01223 325200
PO Box 153, Cambridge, CB3 OHG. U.K    Fax: 01223 327019
=============================================

1995\11\27@143422 by Scott Stephens

picon face
>Has anyone got any simple code that I can 'borrow' to make a '84 wake up
>from sleep mode when an input changes state? I also want some code to put
>the device back into sleep mode.

       ORG     H'000'          ;Reset vector for 16C84 PIC's
       btfsc   STATUS,_PD      ;
       goto    Star1
       goto    Star2

       ORG     H'004'          ;Interrupt vector
       goto    ISR

       ORG     H'005'
Star1   btfsc   STATUS,_TO
       goto    PwrUp           ;Power-up condition, TO & PD = 1
       goto    X_Init          ;WDT time-out, not sleep T0=0, PD=1
Star2   btfss   STATUS,_TO
       goto    Wake_up         ;WDT time-out, sleep T0=0, PD=0

Wake_up sleep

Check page 2-543 of the 94 databook for explanation of the TO and PD Status
bits., and the "SLEEP" instruction. PortB and INT interrupts will wakeup the
processor as well as a watch-dog timer time-out. Execution may start at the
ISR vector H'004' or elsewhere, depending on how the interrupts are configured.

1995\11\28@032313 by SONY-OD

flavicon
face
On Mon, 27 Nov 1995, Mike Barrett wrote:

>Has anyone got any simple code that I can 'borrow' to make a '84 wake up
>from sleep mode when an input changes state? I also want some code to put
>the device back into sleep mode.

This is sample code: " how to sleep and wake-up with portB"

Port B is able to wake up from sleep mode on a change state on its pin:
PB4, PB.5, PB.6 or PB.7,


There is to way to get out from sleep mode:
   - by an interrupt routine (GIE=3D1)
   - by an event (GIE=3D0)

1=B0/ Just configure PB4..PB7 as input for example:=20
       PB4 and PB.7, PB.5 and PB.6 are output

2=B0/ Make a read of port B to latch value,

3=B0/ Set RBIF bit to enable interrupt on portB change

4=B0/ go in sleep mode


--------------------------------
*** A/ Wake-up with interrupt

; before, be sure RBIF is not active, RBIE is not set, bank 0 is activated
; don't forget RBPU bit to set pull-up on or off (depend your hardware)

      org 0            ; RESET VECTOR
      goto start

      org 4            ; INTERRUPT VECTOR
      bcf INTCON,RBIE
      movf PORTB,W
      bcf INTCON,RBIF
      retfie


start: bsf   STATUS,RP0 ; STATUS address =3D 03h (or 83h), RP0 =3D STATUS.5
                       ; SWITCH to bank 1 (register 80h to FFh)
      movlw 090h       ; PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
                       ;  in  out out in out out out out
      movwf TRISB      ; TRISB address =3D 86h

      bcf   STATUS,RP0 ; STATUS address =3D 03h (or 83h), RP0 =3D STATUS.5
                       ; SWITCH to bank 0 (register 00h to 7Fh)

      movf  PORTB,W    ; Read PORTB (PortB address =3D 03h)

      movlw 088h       ; GIE =3D 1 and RBIE =3D 1
      movwf INTCON     ; INTCON address =3D 0Bh

      sleep            ; ENTER SLEEP MODE, low power, no oscillator =20
      nop              ; after sleep instruction, at the wake up the next
instruction is executed before jumping to the INT vector

;   .... program will continue after wake-up and interrupt
      goto start

--------------------------------
*** B/ Wake-up without interrupt

; Another way is to skeep interrupt routine and use only PORTB wakeup
      org 0            ; RESET VECTOR
      goto start


start: bsf   STATUS,RP0 ; STATUS address =3D 03h (or 83h), RP0 =3D STATUS.5
                       ; SWITCH to bank 1 (register 80h to FFh)
      movlw 090h       ; PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
                       ;  in  out out in out out out out
      movwf TRISB      ; TRISB address =3D 86h

      bcf   STATUS,RP0 ; STATUS address =3D 03h (or 83h), RP0 =3D STATUS.5
                       ; SWITCH to bank 0 (register 00h to 7Fh)

      movf  PORTB,W    ; Read PORTB (PortB address =3D 03h)

      movlw 008h       ; GIE =3D 0 and RBIE =3D 1, NO INTERRUPT
      movwf INTCON     ; INTCON address =3D 0Bh

      sleep            ; ENTER SLEEP MODE, low power, no oscillator =20
      nop              ; after sleep instruction, at the wake up
                       ; no interrupt is fetched due to GIE=3D0

      bcf INTCON,RBIE  ; clear no match  condition
      movf PORTB,W
      bcf INTCON,RBIF


;   .... program will continue after wake-up=20
      goto start



Regards,  =20
            Philippe.

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