Addressing multiple PORTs using one Variable


Results 1 to 32 of 32

Threaded View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    923

    Default Addressing multiple PORTs using one Variable

    Hi All,

    I need to address five ports conditionally according to the value of one variable.

    I found some posts about this subject and hoped this thread would help, but unfortunately, it doesn't.

    This a code extract of my current project where timing is crucial and I have to write down a lot of repeating lines of code since FOR/NEXT and GOTOs and GOSUBs take too much time (I'm driving five NeoPixel SW2812B strings with each 28 LEDs/Pixels).

    Code:
    ' PIC 16F690 @20MHz
    #CONFIG
        __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
    #ENDCONFIG
    
    TRISC = %00000000
    
    DEFINE OSC 20
    
    PortPin VAR PORTA.0
    X       VAR BYTE
    X       = 23            ' PORTC.7 - "PORTA.0[23]"
    
    MAIN:
        PORTC.7      = 1    ' OK, obviously will work but useless - just make shure the scope works too
        'PORTA.0[23]  = 1   ' OK but useless
        'PORTA.0[X]   = 1   ' No! Makes a blink in the scope and then stays LOW
        'PORTA[X]     = 1   ' No!, nothing happens, pin stays LOW
        'PortPin[23]  = 1   ' OK but useless   
        'PortPin[X]   = 1   ' No!, nothing happens, pin stays LOW
        'PortPin.0[X] = 1   ' No!, error message "Bad variable size modifier: .0"
        '...
            ASM
                nop
                nop
                nop
            ENDASM
        PORTC.7 = 0         ' have this syntax for tests only here
            ASM
                nop
            ENDASM
            
        GOTO MAIN
    END

    How do I solve this please?
    Last edited by flotulopex; - 23rd July 2024 at 18:13.
    Roger

Similar Threads

  1. Addressing ports via offset using lookup command
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 1st November 2013, 04:50
  2. How to drive 7 segment using multiple ports?
    By guess79 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 20:43
  3. multiple ports ===> one symbol?
    By PICMAN in forum General
    Replies: 4
    Last Post: - 8th March 2005, 23:24
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 17:46
  5. Reading multiple ports
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2004, 18:22

Members who have read this thread : 17

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