Addressing multiple PORTs using one Variable


+ Reply to Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    Code:
        PORTA.0[X]   = 1   ' No! Makes a blink in the scope and then stays LOW
    works ok in your loop for me, although it is much slower , period goes from 3uS to 13uS
    Warning I'm not a teacher

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    "Makes a blink in the scope and then stays LOW"

    It will return to low if:

    1. you force it somewhere in the program to return to low

    2. you PIC is reset for some reason (Watchdog maybe, decoupling cap missing, etc).

    Other than these, I see no way to behave like this.

    Ioannis

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    1. you force it somewhere in the program to return to low

    2. you PIC is reset for some reason (Watchdog maybe, decoupling cap missing, etc).
    All the code and fuses settings are here.

    I soldered the crystal directly on the µC's pins, a 100nF cap is there...

    although it is much slower , period goes from 3uS to 13uS
    Strange. The pulse should be 800ns (nano seconds).


    Okay, I'll give it a try with another 16F690...
    Roger

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Addressing multiple PORTs using one Variable

    Not sure I understand....
    Are you saying that this code works:
    Code:
    MAIN:
        PORTA.0[23]  = 1   ' OK but useless
        ASM
          nop
          nop
          nop
        ENDASM
        
        PORTC.7 = 0         ' have this syntax for tests only here
            ASM
                nop
            ENDASM
            
        GOTO MAIN
    END
    And this isn't:
    Code:
    X VAR BYTE
    X = 23
    MAIN:
        PORTA.0[X]   = 1   ' No! Makes a blink in the scope and then stays LOW
        ASM
          nop
          nop
          nop
        ENDASM
        
        PORTC.7 = 0         ' have this syntax for tests only here
        ASM
          nop
        ENDASM
            
        GOTO MAIN
    END
    The 16F690 has an ADC and comparators.
    Many of the pins are analog. I don't see you setting them to digital mode. PortC.7 is, however, not one of the analog pins but since you're trying to "index" pins with a variable I suspect PortC.7 isn't the only pin you want to use.

    /Henrik.

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Addressing multiple PORTs using one Variable

    Yes Henrik, you might be right.

    Keen to keep the code snippet very (maybe too) short here, I removed all others register settings I have set in the original code.

    I'll give it also a try...when I'm back from office.
    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, 03: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, 19:43
  3. multiple ports ===> one symbol?
    By PICMAN in forum General
    Replies: 4
    Last Post: - 8th March 2005, 22:24
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Reading multiple ports
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th May 2004, 17: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