Help with waking a PIC10F222


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Posts
    70

    Default Help with waking a PIC10F222

    Once again I am at my wits end and need some help.

    I'm trying to set up a PIC10F222 so that it will sleep and then wake up on a pin change at GPIO.3 or at GPIO.0. The datasheet says that wake-ups are possible using these two pins as well as GPIO.1. I have both GP3 and GP0 on pull-up resistors, and I bring the pins low to effect the wake-up. I can get the PIC to wake-up on with a change on GP3, but not on GP0. I have set these pins as input and I have the processor read them before going to sleep. I also have the WDT off and MCLR off (set in the INC file, not in the code). Here is the code I'm working with. Again, a low signal on GP3 (aliased as INT in the code below) wakes the PIC, but a low signal on GP0 (aliased as SDA) does nothing. Can anyone see what I have overlooked?

    Code:
    'Alias pins
    INT     VAR GPIO.3 'interupt (wake-up) pin (pin 6, input only)
    SDA     VAR GPIO.0 'I2C DATA PIN (pin 1),               
    SCL     VAR GPIO.2 'I2C CLOCK PIN (pin 4)
    LIGHT   Var GPIO.1 'INPUT FROM LIGHT SENSOR (pin 3)
                       
    'SET UP VARIABLES
    W0 VAR word 'GENERAL USE
    B0 VAR BYTE 'GENERAL USE
    B1 vAR BYTE 'GENERAL USE
    CNT VAR BYTE 'USED FOR COUNTING minutes (4 bits plus one other bit)
    
    'set initial CNT and W0
    CNT = 0
    w0 = 32768 '%1000000000000000 'SETS FLAG TO 1 AND REST ZERO
    PAUSE 10000
    logdata:
    'Set up for sleep immediately
    OPTION_REG = %10010000 'SET OPTION REGISTER FOR WAKE ON CHANGE
    TRISIO = $00001001 'wake ups on GP3 and GP0
    B0 = GPIO 'read pins to establish change state.
    @SLEEP  'Zzzzzzzzzzzzzzzzz
    'Pic will sleep until an interrupt from the clock or I2C bus
    'Data interface signal from 2nd PIC will pull both SDA and SCL low
    IF sDA = 0 tHEN 'if the data collector is plugged in then 
        iF SCL = 0 THEN
            CNT = 0 'reset count
            TRISIO = $00001111 'all inputs, relinquish I2C bus
            REPEAT 'wait until data collection is done
            PAUSE 100 
            uNTIL LIGHT = 1 'light signal restarts logging
            cnT = 0 'reset count
            GOTO logdata
        eNDIF
    eNDIF

  2. #2
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    So I think it was that pesky ADC register. Gets me every time. I needed to have ADCON0 = 0 in there.

    Now another problem. This pic seems to reset when it wakes from as opposed to carrying on where it left off. Does this mean I lose all my RAM variable values? Is it possible to save and restore the counter to continue a program after sleep? Surely someone has worked with these...

  3. #3
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default @ nop

    ...did you try

    @ sleep
    @ nop

    ?

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default maybe a vBulletin issue

    Quote Originally Posted by bogdan View Post
    ...did you try

    @ sleep
    @ nop

    ?
    Hi brid0030,
    your @SLEEP needs a space @ SLEEP, and as noted above an @ NOP or two sometimes helps too
    Now another problem. This pic seems to reset when it wakes from as opposed to carrying on where it left off. Does this mean I lose all my RAM variable values? Is it possible to save and restore the counter to continue a program after sleep? Surely someone has worked with these...
    How sure about the WDT timer being off are you? Did your programmer override your config due to check box being checked?
    Code:
    OPTION_REG = %10010000 'SET OPTION REGISTER FOR WAKE ON CHANGE
    option reg set to enable on change interrupts and timer0 "1 = Increment on high-to-low transition on the T0CKI pin" seems to me this bit should be zero as you do not use the timer . . .
    Last edited by Archangel; - 21st August 2009 at 04:10.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe. I'll try the spacing correction and the NOPs eventually, I hope. Now I am bogged down in some very mysterious compilation problems. I'll get a list of compilation errors about unrecognized symbols, but the symbols are "TRISIO" and "ADCON0" and "GPIO." And the really wierd part is that once these errors pop up they do not go away. I can delete the supposedly offending piece of code (whatever I last added to the program) and the errors remain. And they persist even when I erase more and more code. I have to cut and replace almost the entire program before the errors cease. I may start a new post about this with the code and everything if I do not find a solution in the next few days. Man...this project just keeps spiraling down...

    By the way, I have tried the OPTION_REG line with the 4th bit high and low--seems to make no difference as the timer is off in both cases.

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by brid0030 View Post
    Thanks Joe. I'll try the spacing correction and the NOPs eventually, I hope. Now I am bogged down in some very mysterious compilation problems. I'll get a list of compilation errors about unrecognized symbols, but the symbols are "TRISIO" and "ADCON0" and "GPIO." And the really wierd part is that once these errors pop up they do not go away. I can delete the supposedly offending piece of code (whatever I last added to the program) and the errors remain. And they persist even when I erase more and more code. I have to cut and replace almost the entire program before the errors cease. I may start a new post about this with the code and everything if I do not find a solution in the next few days. Man...this project just keeps spiraling down...

    By the way, I have tried the OPTION_REG line with the 4th bit high and low--seems to make no difference as the timer is off in both cases.
    I never delete until my program works as expected, I just comment out, make sure to use a semicolon when commenting ASM code. Try saving your project with a different name, sometimes that helps. Sometimes when trying to nail an error I comment out nearly everything, Look at the error, it should tell you which line in which file the offender is by line number, then open that file and look. When you compile PBP and whichever assembler you are using make several files, like any other real compiler does and the errors show up there, maybe PBP signs off on something but the assembler doesn't like it . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. I2C with a PIC10F222 - is it possible
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2009, 04:01
  2. Programming PIC10F222
    By brid0030 in forum General
    Replies: 5
    Last Post: - 19th August 2009, 22:43
  3. Please help a new guy get going with a PIC10F222
    By Quacker in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 2nd June 2006, 01:32
  4. Waking a sleeping PIC
    By anj in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th May 2005, 01:51
  5. PIC12F675 not waking up
    By peterk in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th July 2004, 11:21

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