12f675 making me a crazy person


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Location
    Edmonton AB Canada
    Posts
    52

    Default 12f675 making me a crazy person

    Hi folks,

    Here is some code. I am looking for some wisdom. It runs great. ONCE. It appears that the variable is either never counting to "300", or not getting reset to "10". The input causes the other output to go high, as it should, in a very repeatable manner.
    Ideas?
    Gary

    DEFINE OSC 4
    ANSEL=%00000000
    CMCON=7
    trisio = %00000100

    ' Chubb input gpio.5
    ' Output to panel - Trig var gpio.2
    ' Photo Guy gpio.4
    input gpio.5
    Chubb var gpio.5
    output gpio.4
    Led var gpio.4
    low led
    output gpio.2
    Trig var gpio.2
    low trig

    'Variable for the photo guy
    x var word
    x = 10

    ' Test the photo guy
    PAUSE 2000
    HIGH LED
    PAUSE 250
    LOW LED
    PAUSE 250
    HIGH LED
    PAUSE 250
    LOW LED
    PAUSE 2000

    'start here
    loop:
    if Chubb = 0 then
    high trig
    endif

    if Chubb = 0 then
    if X < 11 then
    X = 12
    gosub cola
    endif
    endif

    if chubb = 1 then
    low trig
    endif

    if x > 11 then
    x = (x + 1)
    endif

    if x >= 300 then
    x = 10
    endif

    if x = 100 then
    GOTO foto1
    endif

    pause 100
    goto loop
    end


    foto1:
    high led
    pause 100
    low led
    pause 250
    high led
    pause 100
    low led
    return
    goto loop

    cola:
    high led
    pause 100
    low led
    return
    goto loop
    end

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You have RETURNs with GOTOs .
    Try going to the subroutines with GOSUB and then RETURN. Not both GOTO and RETURN.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2006
    Location
    Edmonton AB Canada
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Dave,

    There are two iterations of that, in a somewhat silly attempt to validate that the RETURN was working - or failing. No difference. Irrespective, they've been removed.
    The TRIG output goes high and low exactly as it should, when the CHUBB input goes high or low. That tells me the loop is looping. (Loopy?)
    After startup, the TWO led routines do work. ONCE.
    I can't see anything that is unhappy in the counting, the compiler likes it, and it seems to read ok, it just doesn't work.

    What the heck....

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


    Did you find this post helpful? Yes | No

    Default

    Hi Gary,
    try ADCON0 = 0
    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
    Oct 2006
    Location
    Edmonton AB Canada
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Joe,

    No better.
    This is very very strange....

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Something is strange.

    I just tried your code for giggles and this is what happened.
    Executing: "C:\PBP\PBPW.EXE" -ampasmwin -oq -z -p12F675 "C:\MAC\PIC PROGS\TEST\12f675.bas"
    PICBASIC PRO(TM) Compiler 2.50c, (c) 1998, 2008 microEngineering Labs, Inc.
    All Rights Reserved.

    ERROR: RAM END must be defined.
    ERROR: RAM BANKS must be defined.
    ERROR: No LIBRARY statement or LIBRARY parameter.
    ERROR: No LIBRARY statement or MACRO parameter.
    ERROR: Unable to open file PBPMAC.INCHalting build on first failure as requested.
    BUILD FAILED: Tue Sep 15 20:40:41 2009
    It is not your code, something else is the matter. A lot of folks seem to be having problems with this chip....
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE OSC 4
    ANSEL=%00000000
    CMCON=7
    trisio = %00000100
    
    ' Chubb input gpio.5
    ' Output to panel - Trig var gpio.2
    ' Photo Guy gpio.4
    input gpio.5
        Chubb var gpio.5
    output gpio.4
        Led var gpio.4
        low led
    output gpio.2
        Trig var gpio.2
        low trig
    
    'Variable for the photo guy
    x var word
        x = 10
        
    ' Test the photo guy
    PAUSE 2000
        HIGH LED
            PAUSE 250
        LOW LED
            PAUSE 250
        HIGH LED
            PAUSE 250
        LOW LED
    PAUSE 2000
    
    'start here
    loop:
        if Chubb = 0 then
            high trig
            if X < 11 then
                X = 12
                gosub cola
            endif
        else
            low trig
        endif
    
        if x > 11 then
            x = (x + 1)
        endif
    
        if x >= 300 then
            x = 10
        endif
    
        if x = 100 then
            GOTO foto1
        endif
    
    pause 100
    goto loop
    end
    
    
    foto1:
        high led
            pause 100
        low led
                pause 250
        high led
            pause 100
        low led
    goto loop
    
    cola:
        high led
            pause 100
        low led
    return
    end
    This should work

Similar Threads

  1. 12F683 vs 12F675.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th July 2009, 04:58
  2. Instant Interupts with a 12f675
    By wlundonly in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th January 2008, 01:52
  3. 12F675 won't reprogram or erase
    By modifyit in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 19th May 2006, 05:07
  4. 12f675 serial pic2pic
    By tagan in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th March 2006, 22:55
  5. Multitasking 12F675 I/O
    By jpeakall in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th November 2003, 00:57

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