10F222 comes wakes out of sleep, but is confused (like me!)


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231

    Default 10F222 comes wakes out of sleep, but is confused (like me!)

    HI all,

    Stumped on a PIC10F222 not running the same after coming out of SLEEP or NAP.

    After a reset, the led's cycle as expected..... ONCE!
    After that, the only one to toggle is on GPIO2 (Green on pin 4).

    You can see the rem'd commands for SLEEP and NAP, when one or the other are used instead of the PAUSE, it only cycles the other 2 leds on the first pass. Since the green led still cycles, one can guess that it is coming out of its nap. but why do I loose 2 of the ports?

    I am definitely stumped.
    Code:
    '                        10F222 (SOT23-6)                 
    '                 -----------u-----------           
    ' O led cath     -|G0/A0/PGD   G3/MCLR/Vpp|-  10k pull-up     
    '                 -|Vss(-)           Vdd(+) |-        
    ' R led cath     -|G1/A1/PGC   G2/T0CKI/O4|-  G led cath   
    '                   -----------------------         
    '                                           
    define OSC 4
    DEFINE OSCCAL_1K    1           ' read OSCCAL data and use
    OPTION_REG  = 000000               ' 1:2, timer off
    TRISIO  = 0
    ADCON0    = 0               ' All digital for GPIO<0-3>
    Delay        var        byte        ; used to adjust the delay time
    ;****************************************************************************
    Main
    GPIO.0 = 0             'Orange led ON
    pause 50
    GPIO.0 = 1             'Orange led OFF
    GPIO.2 = 0             ' Green led ON
    for delay = 0 to 50
    GPIO.1 = 0             'Red led ON
    pause 20
    GPIO.1 = 1             'Red led OFF
    pause 20
    next Delay
    GPIO.2 = 1             'Green led OFF
    'pause 1000           'THIS WORKS
    'nap 6                 'NO WORKIE
    sleep 1                'NO WORKIE
    goto Main
        END
    I would love to understand this. Any takers?

    Thanks
    Bo

  2. #2
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231

    Default Re: 10F222 wakes out of sleep, but is confused (like me!)

    HI All,

    Well, here is the classic example of RTFM. Whenever I'm tempted to think a problem that I'm seeing is something that I can blame on the folks in Chandler, I should stop and bite my tongue. Maybe a couple of times.

    I thought I had read the datasheet for everything that affected the problem of coming out of sleep. I did searches for issues on a chip that was new to me, and issues with "sleep" or "nap". I was feeling proud that I had eliminated anything that I could test on my end, and I had seen that over 50 people had looked at this post and hadn't offered anything. I thought it was time to ask for professional help.

    An email to our friends in Colorado to show my efforts, followed by a call (I bet that they have probably smashed more than a few phones) to clearly explain my issue resulted in a very polite response:

    "A funny thing happens on the 10F222 when it goes to sleep.
    The ADCON0 register is reset to the power-on state.
    It is shown in section 7.6 and table 7-1 in the datasheet.

    So when it wakes up, the output pins are in analog mode.
    Just add an ADCON0 = 0 after the sleep or nap, and it should fix you up."

    If I had taken the time to study table 7-1 I would have seen that ANS1 and ANS0 are set to 1 on a WAKEUP.

    Lesson learned. Another tidbit to add to my growing stack of "look here before you give up" pile. I think that will be my first rule from now on: If you're having a weird problem, it probably has to do with the ADCON registers.

    A sincere thanks to the folks at meLabs for all they go through for us and also a special thanks to Darrel and the regular contributors here that allow us to do something useful with these possessed little black beasts.

    Bo

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