+ Reply to Thread
Results 1 to 4 of 4

Thread: Need help modifying this code

  1. #1

    Default Need help modifying this code

    Hi there

    I found this code that is similar to what I need but I need to modify it a bit and not to sure how. This code uses a interrupt caused by the closing of a switch to ground to wake from sleep, flashes a LED 10 times and then returns to sleep. I need it so the interrupt wake the PIC, which then starts a timer, which when that expires (providing the switch hasn't opened), flashes the LED until the switch is open again (which would pull the input high via a pullup resistor, which would turn off the LED and return the PIC to sleep.

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    'A change from Vdd to Vss on GPIO.4 will cause the 12F675 to wake up
    'It will then blink a LED times and go back to sleep
    'Front end setup
    Device = 12F675
    Config WDT_OFF,PWRTE_ON,CP_OFF,MCLRE_OFF,BODEN_OFF
    TRISIO=24 'sets GPIO.3 and GPIO.4 as inputs and all others as outputs (or %00011000)
    CMCON=7 'turns off comparator function [CMCON0=7]
    ADCON0=0 'no ADC - doesn't seem necessary but may be a good idea
    ANSEL=0 'no ADC input - IMPORTANT if using ports in digital mode
    VRCON=0 'turns off voltage reference to minimize sleep current
    INTCON=8 'Enables port change interrupt ie GPIE
    IOCB=16 'sets GPIO.4 for Interrupt on change [IOC=16]
    OPTION_REG.6=0 'INT on falling edge
    OPTION_REG.7=0 '00000000 WPU enabled,
    WPU=38 '00100110 = 38 set unused ports 1,2 and 5 tied to weak pull-up resistors
    'Define Variables
    wakeup VAR GPIO.4 'input, interrupt on change.
    LED VAR GPIO.0 'LED output
    x VAR Byte
    'Initial settings
    LED=0
    'Program
    START:
    INTCON.0=0
    DelayMS 100
    @ Sleep
    DelayMS 100
    For x= 1 To 10
    LED=1
    DelayMS 500
    LED=0
    DelayMS 500
    Next x
    GoTo START
    End


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: Need help modifying this code

    Hi
    I suggest you start by registering as a licensed user, and also say which version of the compiler you are using.

    thanks
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  4. #3


    Default Re: Need help modifying this code

    Quote Originally Posted by captainslarty View Post
    Hi
    I suggest you start by registering as a licensed user, and also say which version of the compiler you are using.

    thanks
    Its all good, its all worked out now. Thanks for the tip.

  5. #4
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: Need help modifying this code

    Quote Originally Posted by ajhoward View Post
    Its all good, its all worked out now. Thanks for the tip.
    By ignoring a reasonable request, are you saying you are NOT a legitimate user ?
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

+ Reply to Thread

Similar Threads

  1. Self modifying code feature & GLCD displays
    By rcurl in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 18th April 2008, 21:42
  2. Modifying bits with variables, not constants
    By gramo in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 6th October 2006, 08:07
  3. Self modifying code / Writing to code memory
    By geraintwalesuk in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 16th September 2006, 00:34
  4. Replies: 5
    Last Post: 29th March 2006, 06:47
  5. Modifying Variables
    By j_david in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 19th January 2005, 21:33

Members who have read this thread : 45

Actions :  (Set Date)

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