Charlieplexing using ASM

Discussion in 'The Projects Forum' started by pontoma, Apr 26, 2013.

Thread Status:
Not open for further replies.
  1. pontoma

    Thread Starter New Member

    Apr 23, 2013
    2
    0
    Hi I am trying to charlieplex 8 LEDS using the PIC12F609. I am using them to create something like a stop light sort of example.
    In my program I have written a function that will turn on each LED. I have never used .asm before and have run into a lot of problems. I am having the biggest problem getting the program to go to the next LED and so on.
    Here is my code:

    ; PIC12F609 Project
    list p=12F609
    #include <p12F609.inc>
    __CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTOSCIO & _IOSCFS_4MHZ
    UDATA
    dc1 RES 1
    dc2 RES 1
    dc3 RES 1
    RESET CODE 0x000
    led1
    banksel GPIO;
    movlw b'000001'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000100';
    movwf TRISIO;
    call delay
    goto led2

    led2
    banksel GPIO;
    movlw b'000010'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000100';
    movwf TRISIO;
    call delay
    call delay
    goto (next led and so on)

    led3
    banksel GPIO;
    movlw b'000001'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000010';
    movwf TRISIO;

    led4
    banksel GPIO;
    movlw b'000010'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000001';
    movwf TRISIO;

    led5
    banksel GPIO;
    movlw b'000100'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000001';
    movwf TRISIO;

    led6
    banksel GPIO;
    movlw b'000100'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000010';
    movwf TRISIO;

    led7
    banksel GPIO;
    movlw b'010000'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000010';
    movwf TRISIO;

    led8
    banksel GPIO;
    movlw b'100000'
    movwf GPIO;
    banksel TRISIO;
    movlw b'000010';
    movwf TRISIO;

    delay
    movlw .50
    movwf dc1
    outerloop
    movlw .100
    movwf dc2
    middleloop
    movlw .250
    movwf dc3
    innerloop
    nop
    decfsz dc3,f
    goto innerloop
    decfsz dc2,f
    goto middleloop
    decfsz dc1,f
    goto outerloop
    return;
    END

    Does goto not work as simple as I thought it would?
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Code ( (Unknown Language)):
    1. goto led2
    2.  
    3. led2
    There's no need for a goto to the next instruction, unless you are making a delay.
    You are changing to whatever bank TRISIO is in and then calling delay, so if your variables dc1-3 are not in that bank there could be problems.
     
  3. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
Loading...
Thread Status:
Not open for further replies.