WRITECODE stores wrong 14-bit word values in FlashMEM


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Great! Glad it helped.
    Quote Originally Posted by BobPigford
    Makes me wary of using array variables.
    Nothing to worry about there. Arrays work perfectly with PBP.
    And yes, PBP makes sure the arrays will fit in a BANK of RAM.

    The crossing boundary warnings refer to the FLASH memory used by the program. The same area of memory that you are WRITECODEing to.
    Arrays can not cause that warning.

    Array indexes always start at 0.
    So if you have a word array of 3 elements, the index goes from 0 to 2.
    It's easy to forget and try to use 1 - 3, but 3 would be outside of the array, probably a RAM location used by another variable.

    PBP does not do any "Range Checking". It's up to you to stay within the bounds of the array.

    Just about any good program will use arrays in some form or another.
    So yup, time to learn ... then play ... then learn more ...
    <br>
    DT

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Darrel,
    From reading other posts and other documentation (if I understood them correctly) when using arrays in a pic16fxxx and if the program crosses the memory boundary then that would be looking for trouble. In other words, if you are using arrays all over the place in your program, then your program has to fit in one memory block which is ussually not the case. Otherwise, the program won't work properly.
    I personally like arrays. They make your program looks neat and more profesional, but also my programs are usually bigger than 2K.

    Any comments on this?

    Robert

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    NO! Not true at all.

    The size of your program has NO effect on arrays.
    Arrays are in RAM, the program is in FLASH.

    You may be thinking of the problems that can happen with the BRANCH command if the code is larger than 2K. In which case you need to use BRANCHL.
    DT

  4. #4
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Smile Well, I was careful about arrays, perhaps I missed something.

    Darrel, et al,

    I understand going out of bounds of a dimensioned array, and that arrays start at 0. I believe that my use of array variables was correct, but I will go back and look again. Perhaps I missed something.

    I am glad to hear that PBP did not let me down, per se, as array variables are held in RAM and arrays crossing any page boundaries are handled by PBP.

    So, I guess I will have to go back and bang out the code with array variables again. It may be a while, but I will report back.

    Thanks to all for your help!
    Bob Pigford
    Newark, DE, USA

  5. #5
    Join Date
    Jan 2009
    Location
    Delaware
    Posts
    19


    Did you find this post helpful? Yes | No

    Cool Oops - I "misspoke" about arrays and boundaries

    Quote Originally Posted by BobPigford View Post
    I am glad to hear that PBP did not let me down, per se, as array variables are held in RAM and arrays crossing any page boundaries are handled by PBP.
    Oops. I should not have talked about arrays crossing any boundaries since Darrel reminded me that they are in RAM. Sorry.

    Bob

  6. #6
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Darrel,
    I think my confusion comes from the PicBasic Pro Manual, section 4.5, "Arrays".
    "Arrays must fit entirely within one RAM bank on 12-bit, 14-bit or pic17cxxx devices."

    Yeap, I know the program is not stored in RAM. But, what are the implications of this limit to one RAM bank for arrays? Would it be only the limited number of elements in an array?

    Robert

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    But, what are the implications of this limit to one RAM bank for arrays? Would it be only the limited number of elements in an array?
    Exactly.

    The largest amount of GP ram in a 16F's bank is 96 bytes. (chip dependant)
    So the biggest WORD array you can make has 48 elements.

    You could have 3 arrays with 48 words, but not all in one.

    hth,
    DT

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. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  3. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

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