Custom array of ports using array?


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    Michigan
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Plus I think an array should start with variable 0 not 1. So it would be 0 through 9.

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    blainecf,
    I am not sure this will work like you expect. When you declare an array variable, it is acually pointing to a series of consecutive RAM addresses. So later, when you use the variable, it goes to the address and uses the value currently at that address. What you are looking to do is create an array that is actually pointing to the addresses represented by the individual pins (which are not even consecutive).

    After playing with it a little and looking at the .lst file, I don't know if this can be done in PBP. Once you have created the array, any further references to the array are modifying/reading the contents, not the address. The only info in the manual I see is assigning a label to a specifc pin. Which is handled using different ASM commands.

    Maybe one of the real gurus could chime in here and set me straight if I'm wrong (Melanie? Darrel?). Or provide a workaround to do the job.

    Hope to get a better answer,
    Steve

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Last edited by paul borgmeier; - 13th June 2006 at 20:02.

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile a little more info ...

    Although slightly contrived and uses more RAM - this does it.

    Code:
    Relay var Byte[4]
    x var byte
    i var byte
    
    Relay[1] = 14  'RB6
    Relay[2] = 20  'RC4
    Relay[3] = 26  'RD2
    main:
    ' cycle through relays
    for i = 1 to 3
         x = relay[i]
         porta.0[x]=1
         PAUSE 1000
         porta.0[x]=0
         PAUSE 300
    next i
    Paul Borgmeier
    Salt Lake City, Utah
    USA

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. Custom array of pins
    By bmagistro in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 28th March 2009, 23:15
  4. Crystalfontz LCD
    By jman12 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 9th February 2007, 15:04
  5. Making Array of two ports
    By John7 in forum General
    Replies: 3
    Last Post: - 5th March 2005, 02:20

Members who have read this thread : 2

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