Menu

need chip to wake up from sleep?

Help
2010-05-07
2013-05-30
  • Nobody/Anonymous

    it runs, then sleeps, but does not wake when i put pull gpio.1 high?
    Here is my code:
    #chip 12F683, 8 'mhz
    #config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off

    dir gpio.0 out
    dir gpio.1 in
    on interrupt gpiochange call wake_up

    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    gpie=0
    gpif=0
    asm sleep
    nop
    goto main

    sub wake_up
    goto main
    end sub

     
  • kent_twt4

    kent_twt4 - 2010-05-08

    1.  The easiest is to enable MCLRE in config, and put a button on MCLR, no interrupt routine required.  .

    2.  For interrupt on pin change, the interrupt routine needs to know which pin is being used.  So add this line prior to Main:

    Set IOC.IOC1 On ;Set interrupt on change for gpio.1

    3.  If you use "On Interrupt EXTINT0 call wake_up" no pin setup is required.  The interrupt pin (INT) is gpio.2.

    Also, GCBasic clears the appropriate flags in the interrupt routine (i.e. gpie=0 and gpif=0 not required).

     
  • Nobody/Anonymous

    That works god for the first cycle, but the chip never returns to sleep, it just loops the main and "skips" the sleep command?
    #chip 12F683, 8 'mhz
    #config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off

    dir gpio.0 out
    dir gpio.2 in
    On Interrupt EXTINT0 call wake_up

    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main

    sub wake_up
    set gpio.0 on
    wait 250 ms
    set gpio.0 off
    wait 250 ms
    set gpio.0 on
    wait 250 ms
    set gpio.0 off
    wait 250 ms
    goto main
    end sub

     
  • kent_twt4

    kent_twt4 - 2010-05-11

    Keep the interrupt routine as short as possible.  Long delays are bad.  Increment a counter, assess a condition, or toggle a boolean value and leave the interrupt ASAP.  Process information from interrupt, at top of main.

     
  • Nobody/Anonymous

    even with it this way it still loops and does not return to sleep:
    #chip 12F683, 8 'mhz
    #config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off

    dir gpio.0 out
    dir gpio.2 in
    On Interrupt EXTINT0 call wake_up

    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main

    sub wake_up
    goto main
    end sub

     
  • kent_twt4

    kent_twt4 - 2010-05-11

    Works for me.  Sounds like a hardware problem, whereby the PIC wants to reset itself all the time.  Things to check:

    1)  Be sure MCLR pulled up with 10k resistor.
    2)  Bypass the PIC with a 0.1uf cap as close to Vdd and Vss as possible.
    3)  Is the programmer holding the PIC in reset?  disconnect and see.
    4)  If the PIC circuit is soldered on strip board, recheck for solder bridges.
    5)  Running batteries?, check for min 3V (preferably more) for 8Mhz osc.
    6)  Noisy power supply?  Bypass with 100uf and 0.1uf caps.

     
  • Nobody/Anonymous

    I tried all of those things, it acts likr the interrupt needs to be cleared and is not getting cleared. it runs through once and sleeps and then wakes when i pull the pin high just fine, but then when the pin goes low and stays low it never goes back to sleep after the first time, it just runs through the main skipping over the sleep?

     
  • kent_twt4

    kent_twt4 - 2010-05-12

    Leave out the goto main in the wake-up sub.  GCBasic will return to its proper place after the retfie command in the interrupt service routine.

     
  • Nobody/Anonymous

    that did it thanks

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.