10F222 wake/sleep


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default 10F222 wake/sleep

    Ladies and Gents,

    I've been playing around with the 10F222 and its sleep/wake on pin change. Not trying to show my ineptness here but what do they mean by reading the input pins? This code works:
    Code:
    CLEAR
    DEFINE OSC 4
    adcon0 = 0         ' Turn off ADC
    option_reg = %00001000       ' enable wake on pin, weak pull ups, prescaler to wdt         
    osccal = %00000000            ' oscillator calibration
    trisio = %1101      ' GP1 only is output
    gpio = 0 ' turn everything off
    
    LED VAR gpio.1
    i VAR BYTE
    
    start_here:
    
    IF gpio.0 = 0 THEN GOSUB Light_LED
    IF gpio.3 = 0 THEN GOSUB Light_LED
    SLEEP 5
    
    GOTO start_here
    
    Light_LED:
    i = 0
        FOR i = 0 TO 3
        TOGGLE LED
        PAUSE 8000
        NEXT i
    RETURN
    
    END
    I'd like to know if I did it right or is there something more subtle, or bodacious, I should be doing.

    I've, I think, attached the page and my code. Constructive help greatly appreciated.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: 10F222 wake/sleep

    Hi AvionicsMaster

    Here is a code using IOC and Sleep.

    Code:
    '****************************************************************
    '*  Name    : Temporizador 3m p/ Lavar Dentes.BAS               *
    '*  Author  : Hugo Oliveira                                     *
    '*  Notice  : Copyright (c) 2012 ProSystems                     *
    '*          : All Rights Reserved                               *
    '*  Date    : 01-03-2012                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Proteus + Circuito com SOT-23 e CR2032            *
    '*          : 10F222 - Wake from sleep através de IOC no GP3    *
    '****************************************************************
    @ __config _IOFSCS_4MHZ & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _MCPU_ON
    
     DEFINE OSC 4
    
     '===================SRF AND PINOUT CONFIGURATION - 1-In / 0-Out=================
                  '76543210
         TRISIO = %00001000
           GPIO = %00000000
     OPTION_REG = %00000000 'OPTION_REG.7 - Wake on change bit 0=Enable
         ADCON0 = %00000000 'Analog pins disable
    
    '==================================ALIAS========================================
     VAZIO1 VAR GPIO.0
     VAZIO2 VAR GPIO.1
     LED    VAR GPIO.2
     MCLR   vAR GPIO.3
     
    '=================================VARIABLES=====================================
     I VAR BYTE
     
    '================================MAIN LOOP======================================
    @ movlw 0x01A  ;OSCCAL Value
    @ movwf OSCCAL
    Main:
    
    
     WHILE MCLR = 0
     WEND
     
     FOR I = 0 TO 119 '~120 Segundos a Piscar de 1 em 1 Segundo
        HIGH LED
        PAUSE 500 
        LOW LED
        PAUSE 500
     NEXT
    
     FOR I = 0 TO 59  '~30 Segundos a Piscar de 0,5 em 0,5 Segundo
        HIGH LED
        PAUSE 250 
        LOW LED
        PAUSE 250
     NEXT
    
     HIGH LED
     PAUSE 30000     '~30 Segundos sempre ligado
     LOW LED 
     'Sequencia de finalização
     HIGH LED: PAUSE 100: LOW LED: PAUSE 100
     HIGH LED: PAUSE 100: LOW LED: PAUSE 100
     HIGH LED: PAUSE 100: LOW LED: PAUSE 100
     
     I = GPIO     'Must read GPIO before entering sleep. Read the Datasheet
    @ SLEEP
    @ NOP
    GOTO Main
    END
    Thanks and Regards;
    Gadelhas

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: 10F222 wake/sleep

    Hi,
    There's a slight difference between the PBP command SLEEP and the ASM instruction SLEEP.

    The PBP command uses the ASM instruction sleep but relies on the watchdog timer to periodically wake the PIC up in order to keep track of time. If you don't want the PIC to periodcally wake up you need to disable the watchdog and use the ASM instruction SLEEP directly.

    What they mean by "reading the pins" is that before entering sleep mode you should make a "dummy read" of the pins in order to clear any mismatch which might otherwise cause the PIC to wake right back up.

    /Henrik.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: 10F222 wake/sleep

    On some PIC chips there is an option in Config Word that allows the WDT to be enabled when PIC is running and automatically disabled when it enteres SLEEP (in ASM command, not PBP sleep).

    For example 16F1826/27. See page 44 of the datasheet at http://ww1.microchip.com/downloads/e...Doc/41391D.pdf

    Ioannis

Similar Threads

  1. Cannot wake from SLEEP
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st May 2013, 08:47
  2. Replies: 1
    Last Post: - 11th November 2011, 08:01
  3. 16F690... How to wake from sleep?
    By Heckler in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th July 2011, 23:07
  4. 16F181: can't wake up from sleep
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th January 2010, 05:33
  5. wake up from sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2007, 18:09

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts