Stupid array question


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    RUBiksCUbe's Avatar
    RUBiksCUbe Guest

    Post Stupid array question

    I'm working on an LED matrix project that involves displaying data on an 8 x 80 LED matrix (multiplexed of course). I was planning on storing the data to be displayed in hex form in my PIC18F252s EEPROM, which I would then be able to look at using .Bit0 or .Bit1 to see if an LED needs to be on (for example, $AA in binary is 10101010, which would mean that every other LED is on). The only problem with this plan is that the EEPROM on the 18F252 is only 256 bytes, leaving room for less than 125 rows of LEDs, which just isn't enough.

    If anyone knows a good way to somehow compress data, that might be usefull, but I was thinking about storing the display data in arrays, that way I could easily switch between different messages.

    So, the real question now:
    Is there any way to store a bunch of data in an array on one line?

    In java you can do this:
    Int[] test = {5, 6, 7};

    Can you do anything like that in PBP? It would make coding much easier, as opposed to going like this:
    message[0] = $AA
    message[1] = $2C
    message[2] = $4D

    and so on...

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RUBiksCUbe
    .... switch between different messages.
    ....
    Will the "different messages" come from an external source or there will be a fixed pattern inside the program and once the PIC is programmed then that fixed pattern will never be changed?



    --------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Smile

    As Sayzer is hinting, if your data does not change after you do the initial programming, you could use the LOOKUP or LOOKUP2 command. (or just the READCODE command referenced below if you preloaded your data)

    If your data is going to change, you could use WRITECODE and READCODE. Also see: http://www.picbasic.co.uk/forum/showthread.php?t=137 for reference
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    RUBiksCUbe's Avatar
    RUBiksCUbe Guest


    Did you find this post helpful? Yes | No

    Default

    The READCODE command actually looks perfect for me. Thanks for pointing that out.

    The PIC will switch between different messages when external buttons are pushed.

  5. #5
    RUBiksCUbe's Avatar
    RUBiksCUbe Guest


    Did you find this post helpful? Yes | No

    Angry

    Well, it was too good to be true. Whenever I compile with this in my project:

    Code:
    Asm
    CODE 1400
    DB 0
    DB 220
    DB 476
    DB 384
    DB 384
    DB 476
    DB 220
    DB 0
    DB 999
    Endasm
    I get some nice errors:

    Found directive in column 1. (CODE)
    Directive only allowed when creating an object file
    Found directive in column 1. (DB)
    Argument out of range. Least significant bits used.

    There are 15 errors total, but they're all just copies of those 4.

    Am I missing something?

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


    Did you find this post helpful? Yes | No

    Smile

    You need to indent your program like that below. However, I believe DB is used for bytes only and you must use packing to place the word (i.e., DB 476 will not do what you want)? Others with more 16 bit processor Assembly experience might be able to offer a (better) solution in ASM.

    You might want to consider using PBP's WRITECODE instead of the ASM for the initial write. Look here http://www.picbasic.co.uk/forum/show...ight=writecode and also search “WRITECODE” on this forum for examples of how to write to the 18F family, which is not as straight forward as one might think.

    Code:
    Asm
         CODE 1400
         DB 0
         DB 220
         DB 476
         DB 384
         DB 384
         DB 476
         DB 220
         DB 0
         DB 999
    Endasm
    Good Luck

    edit: or consider LOOKUP2 tables
    Last edited by paul borgmeier; - 3rd September 2006 at 08:29. Reason: added option?
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  2. Array Question....please help
    By jmoskalski in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st October 2009, 01:29
  3. Stupid question about LCDOUT
    By Glenn in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 7th October 2008, 21:37
  4. Stupid question
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 20th July 2007, 05:47
  5. How to saparate variable to array and GLCD Question
    By pramarn in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 4th October 2006, 03:42

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