Help with this code, it compiles but doesn't work on my simulations


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2009
    Posts
    24

    Default Help with this code, it compiles but doesn't work on my simulations

    Code:
    @ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
    DEFINE OSC 8
    TRISIO = %101011
    CMCON0 = 7 
    start:   IF      GPIO.1 = 1 then 
             high    GPIO.4
    alarm:   FREQOUT GPIO.2,1500,1000
             pause 1500
             goto alarm
             else
             low GPIO.2
             pause 100
             low GPIO.4
             pause 100
             goto start
             endif
    end

    this code compiles, i'm sure that i selected the correct device but it doesn't work

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    joseph, What makes you think it doesn't work? The statememts you have here:
    alarm: FREQOUT GPIO.2,1500,1000
    pause 1500
    goto alarm
    will loop forever..... Not a very good practice...

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Apr 2009
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Help

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Try adding:

    ANSEL = 0 ' Analog select set to digital, pg 69 data sheet
    ADCON0 = 0 ' A/D turned OFF, pg 68 of data sheet

    Also, have you used a 10K resistor to pull down GPIO.1 so it reeds logic 0 until the switch is pressed and GPIO.1 is taken high

  5. #5
    Join Date
    Apr 2009
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    i'l try to add that and regarding the pull down yes i did placed a pulldown resistor

  6. #6
    Join Date
    Apr 2009
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    whoa! it worked! thankyou malc-c

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I'm not going to hammer on about how you must read the data sheets for these devices, I'll leave that to some of the others

    Glad to of helped.

Members who have read this thread : 1

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