10F222 Wake on pin change


Closed Thread
Results 1 to 12 of 12

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Hi;

    Here is a program that i wrote in the past.
    Code:
    '****************************************************************
    '*  Name    : Temporizador 3m p/ Lavar Dentes.BAS               *
    '*  Author  : gadelhas                                          *
    '*  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
     GPWUF  var STATUS.7
     
    '=================================VARIABLES=====================================
     I VAR BYTE
     C VAR BYTE: C = 0
     
    '================================MAIN LOOP======================================
    @ movlw 0x01A  ;OSCCAL Value
    @ movwf OSCCAL
    
     IF GPWUF = 0 THEN DESLIGA  'Test what caused the Reset
     
    Main:
    
     WHILE MCLR = 0    'If button pressed for 3 seconds, turn on led
        PAUSE 100
        C = C + 1
        IF C = 30 THEN LIGA
     WEND
     
     FOR I = 0 TO 119 '~120 Segundos a Piscar de 1 em 1 Segundo
        HIGH LED
        PAUSE 500
        GOSUB VERIFICA 
        LOW LED
        PAUSE 500
        GOSUB VERIFICA
     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
        GOSUB VERIFICA
     NEXT
    
     HIGH LED
     FOR I = 0 TO 59  '~30 Segundos sempre ligado
         PAUSE 500     
         GOSUB VERIFICA
     NEXT
     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
    
    DESLIGA:
     C = 0
     I = GPIO     'Must read GPIO before entering sleep. Read the Datasheet
    @ SLEEP
    @ NOP
    GOTO Main
    
    '================================SUB-ROUTINES===================================
    LIGA:
        HIGH LED
        PAUSE 1000
        WHILE MCLR !=0
        WEND
        LOW LED
    GOTO DESLIGA
    
    VERIFICA:
     IF MCLR = 0 THEN
         C = C + 1
         IF C = 6 THEN
             '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
             PAUSE 1000
             GOTO DESLIGA
         ENDIF        
     ENDIF
    RETURN
    END
    Thanks and Regards;
    Gadelhas

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    With that said I really wouldn't want to run it at anything above 5.5V......
    I agree...But for that you can just add a diode in series to lower the voltage down a bit.

    Regards
    Rui

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Good idea on the diode. Thanks.

    I know what RTFDS says but for what I'm doing I assume the four AAA batteries are putting out somewhat less than 1.5V and typically the four pack is close to 5.6V. After a short period they are below the 5.5V level and stay like that for a long time with only a 3uA draw. They'll last even longer if I can get it down in the nano Amp range.

    I've yet to try the ASM sleep but will try soon. Thanks for ideas.

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Brand new batteries will actually put out more than 1.5V. I'd recommend the diode. Also helps for the day you accidentally put them in backwards. Or use NiCDs.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,161


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Would a low drop off 7805 help?

    Robert

  6. #6
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    How low is low? They usually need over a volt. Can you point to a spec sheet?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Hi,
    I don't really see the point of linear regulator. A 5V one, LDO or normal, will drop out of regulation pretty quick, then it behaves as if it wasn't there in first place - or worse. Using a lower voltage like 3.3V or 2.5V will only turn useful energy into heat in the regulator so that's no good either.

    The "best" way would of course be a switching type boost/buck converter/regulator so that the PIC can be fed 2.5V (or whatever) from "any" supply voltage, the good thing about this is that the PIC Draws much less current at lower supply voltages so provided the converter/regulator is efficient you'd get more use out of the batteries. But, it adds complexity so.....perhaps use 3 cells in series instead of 4.

    /Henrik.

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,161


    Did you find this post helpful? Yes | No

    Default Re: 10F222 Wake on pin change

    Quote Originally Posted by Charlie View Post
    How low is low? They usually need over a volt. Can you point to a spec sheet?

    I haven't used one yet. I checked a few and can't find one that comes even close to what is needed here.

    They should call them NAMDO; Not As Much Drop Off instead of LDO.

    Robert

Similar Threads

  1. 10F222 wake/sleep
    By AvionicsMaster1 in forum PBP3
    Replies: 3
    Last Post: - 23rd August 2013, 08:03
  2. Interrupt-on-Change-pin!
    By PICante in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th February 2009, 20:22
  3. HELP !!! How change the voltage of a pin ????
    By stormdacta in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 21st August 2007, 20:55
  4. ? about sleep/wake on pin change and WDT
    By kessral in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 25th January 2007, 23:25
  5. 16F676 Interupt on Change pin determination
    By BGreen in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 5th May 2006, 17:04

Members who have read this thread : 0

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

Posting Permissions

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