"Variable already an alias" - is there a way to avoid this?


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    I am sure there are other ways...

    Ioannis

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    you can lead a horse to water but ....

    any pin can be addressed with PORTA.0[offset]
    Warning I'm not a teacher

  3. #3
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    So say

    FOR A=1 to 20
    HIGH PORTA+A
    NEXT

    will work?

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    So say

    FOR A=1 to 20
    HIGH PORTA+A
    NEXT

    will work?
    do you think that looks even close ?


    Code:
    FOR A=0 to 20
      PORTA.0[A]=1
    NEXT
    assuming the 18 [chip dependent] pins in that range are set as digital output


    Warning I'm not a teacher

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    I don't mean to be rude or to offend anyone but do you actually read and/or try any of the solutions you are provided with - for free - here or is the purpose of your post simply to vent your ideas on how you EXPECT expect everytning to work and then continue doing it "your way"?

    Several times now you've been shown the correct syntax to access any pin using an offset and it's (for example, using PortA.0 as the "base address") PortA.0[offset] and yet you ask if PORTA+A will work, I'm sorry but I don't get it. And to be perfectly clear, no, PORTA+A will not do what you want.

    So in your example:
    Code:
    FOR A=1 to 20
     HIGH PORTA.0[A]
    NEXT
    I would not use HIGH though but instead PORTA.0[A] = 1 since that will produce smaller and faster code and it will work provided TRIS are cleared for the pins in question.

    /Henrik.

  6. #6
    Join Date
    Feb 2013
    Posts
    1,153


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    Well you're the pros, for me a lot of these strange brackets and other syntax things are quite hard to understand, because I've learned BASIC on ZX Spectrum, almost 35 years ago So I'm asking to clarify.

    So back to this:


    FOR A=1 to 32
    PORTA.0[A]=1
    NEXT
    Will make all ports of PORTA/PORTB/PORTC/PORTD high in sequence, right? (All TRIS and other yada-yada are already set).

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    if it does not work post code and schematic of your attempt, its a simple test
    Warning I'm not a teacher

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: "Variable already an alias" - is there a way to avoid this?

    FOR A=1 to 32
    PORTA.0[A]=1
    NEXT
    Will make all ports of PORTA/PORTB/PORTC/PORTD high in sequence, right? (All TRIS and other yada-yada are already set).
    Since you start your offset value (the FOR loop) at 1 it the first bit to be set will be "one away" from PortA.0, in other words PortA.1 and then contiune 32 bits "up from there", so you will write to the first bit of the register comming after PortD - that can ruin your day.

    But, as Richard says, TRY IT for crying out loud :-) Investigate how it works, does it do what you expect, change something and see if you get the expected result and if not think about WHY.

Similar Threads

  1. How to do the "SerIN" and "SerOut " for the usb ?
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th March 2015, 02:01
  2. Replies: 0
    Last Post: - 14th November 2013, 03:32
  3. Replies: 3
    Last Post: - 15th October 2012, 08:06
  4. AN Question for "word" variable read The serial port
    By redfoen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2007, 17:39
  5. Replies: 1
    Last Post: - 16th February 2005, 20:05

Members who have read this thread : 1

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