PORTC bits not 'latching' on 16F610


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1

    Default PORTC bits not 'latching' on 16F610

    simple little xmas lights project which i posted several weeks ago... RGB LEDs ramping up and down with software PWM...

    The same program compiled for the 18F4550 works correctly, however, when compiled for the 16F610 as soon as PORTC.1 goes high it makes PORTC.0 low even though i've set it high...

    For the fun of it, i've included the source code below... Can anyone see any problems with it? Have i missed something?

    Thanks

    Code:
    Define  OSC				8						' Set clock speed
    
    TRISA = %00000000
    PORTA = %00000000
    TRISC = %00000000
    PORTC = %00000000
    
    RED VAR PORTC.0
    GREEN VAR PORTC.1
    BLUE VAR PORTC.2
    REDSCALE VAR WORD
    GREENSCALE VAR WORD
    BLUESCALE VAR WORD
    Aloop VAR byte
    Bloop VAR BYTE
    DUTY var BYTE
    clear
    REDSCALE = 1
    BLUESCALE = 1
    GREENSCALE = 1
    DUTY = 100
    
    gosub powerupred
    MAIN:
    gosub powerupgreen
    gosub powerdownred
    gosub powerupblue
    gosub powerdowngreen
    gosub powerupred
    gosub powerdownblue
    GOTO MAIN
    
    POWERUPRED:
    for Aloop = 1 to DUTY
    FOR Bloop = 1 to REDSCALE
    HIGH RED
    pause Aloop
    LOW RED
    pause (duty-Aloop)
    NEXT Bloop
    NEXT Aloop
    HIGH RED
    return
    
    POWERDOWNRED:
    for Aloop = 1 to duty
    FOR Bloop = 1 to REDSCALE
    HIGH RED
    pause (duty-Aloop)
    LOW RED
    pause Aloop
    NEXT Bloop
    NEXT Aloop
    return
    
    POWERUPGREEN:
    for Aloop = 1 to duty
    FOR Bloop = 1 to GREENSCALE
    HIGH GREEN
    pause Aloop
    LOW GREEN
    pause (duty-Aloop)
    NEXT Bloop
    NEXT Aloop
    HIGH GREEN
    return
    
    POWERDOWNGREEN:
    for Aloop = 1 to duty
    FOR Bloop = 1 to GREENSCALE
    HIGH GREEN
    pause (duty-Aloop)
    LOW GREEN
    pause Aloop
    NEXT Bloop
    NEXT Aloop
    return
    
    POWERUPBLUE:
    for Aloop = 1 to duty
    FOR Bloop = 1 to BLUESCALE
    HIGH BLUE
    pause Aloop
    LOW BLUE
    pause (duty-Aloop)
    NEXT Bloop
    NEXT Aloop
    HIGH BLUE
    return
    
    POWERDOWNBLUE:
    for Aloop = 1 to duty
    FOR Bloop = 1 to BLUESCALE
    HIGH BLUE
    pause (duty-Aloop)
    LOW BLUE
    pause Aloop
    NEXT Bloop
    NEXT Aloop
    return

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Place ANSEL = 0 in the top section to disable A/D.

    Analog pins always read as 0, and the HIGH/LOW commands cause the whole port to be read, bits flipped, and the whole value being placed back on the port, so previous pins always get returned to 0.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3


    Did you find this post helpful? Yes | No

    Default

    That works, thank you

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