piclist 1995\11\28\032313a >
Thread: Wake and Sleep code for 84 device
www.piclist.com/techref/index.htm?key=wake+sleep+code
flavicon
face BY : SONY-OD email (remove spam text)



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.
<9511280822.AA28954@MIT.EDU>

See also: www.piclist.com/techref/index.htm?key=wake+sleep+code
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Wake and Sleep code for 84 device

month overview.

new search...