Hello!

Thanks again to all who pointed out that writing to FlashRAM has to be done in blocks and starting at addresses where the last two bits of address are 00!
That knowledge allowed me to make my program work OK, but not in an efficient way. I could not get array variables to work for me. I ended up creating 36 separate word variables to get the job done.

But, I realized that I had not posted anything about my array variable issues since last April. I am still wondering what I was doing wrong. Please help me better understand array variables.

Below are some snippets of my code that are germane to the issue.

Program background:

My program runs on a PIC16F876A at 20 mHz

At run time, I stuff 14-bit word sized data from a PC into upper FlashRam, then with a switch closure, I change to a routine that reads the words at those addresses and displays them bit-wise. The serial transfer of words and stuffing into FlashRAM works well and I have verified that the correct 14 bit words are correctly placed into FlashRAM.

When I read words from FlashRAM, these words are put into 2 of my array variables for my subsequent bit-wise display.

It helps to "conceptualize" the layout of those array variables like this:

MAX1A[0] MAX2A[0] MAX3A[0] MAX4A[0] MAX5A[0] MAX6A[0]
MAX1B[0] MAX2B[0] MAX3B[0] MAX4B[0] MAX5B[0] MAX6B[0]

MAX1A[1] MAX2A[1] MAX3A[1] MAX4A[1] MAX5A[1] MAX6A[1]
MAX1B[1] MAX2B[1] MAX3B[1] MAX4B[1] MAX5B[1] MAX6B[1]

MAX1A[2] MAX2A[2] MAX3A[2] MAX4A[2] MAX5A[2] MAX6A[2]
MAX1B[2] MAX2B[2] MAX3B[2] MAX4B[2] MAX5B[2] MAX6B[2]

This comprises 12 array variables, each with 3 elements [0, 1, 2].

After I display them (display code not shown - it works well), I move those last 6 words from the last array elements to their left adjacent array variables with a "riffle" routine that also works well (shown in my code snippets below). Then the program loops and repeats reading words from FlashRAM and displaying them until I reach a preset address in upper FlashRAM.

What DOES NOT work is the stuffing of words into the array elements in the last column. Wrong values appear there, and the program slows to a crawl, updating about once every 30 seconds or even longer. When complied, no errors are generated.
But when I use 36 separate word variables in place of the array elements, all works well.

Snippets of my code that apply:

Code:
'snippet from my program
'array variables declared
MAX1A   VAR WORD[2]
MAX1B   VAR WORD[2]
MAX2A   VAR WORD[2]
MAX2B   VAR WORD[2]
MAX3A   VAR WORD[2]
MAX3B   VAR WORD[2]
MAX4A   VAR WORD[2]
MAX4B   VAR WORD[2]
MAX5A   VAR WORD[2]
MAX5B   VAR WORD[2]
MAX6A   VAR WORD[2]
MAX6B   VAR WORD[2]

'code loop that gets WORD values from FlashRAM and stuffs it into
'the elements of 2 arrays
    readcode mempntr, MAX6A[0]
    mempntr = mempntr + 1
    readcode mempntr, MAX6B[0]
    mempntr = mempntr + 1
    readcode mempntr, MAX6A[1]
    mempntr = mempntr + 1
    readcode mempntr, MAX6B[1]
    mempntr = mempntr + 1    
    readcode mempntr, MAX6A[2]
    mempntr = mempntr + 1
    readcode mempntr, MAX6B[2]
    mempntr = mempntr + 1
    
'other code that moves word values from one array element to another
'so it can be displayed by other routines, then goes back 
'6 more words, displays them, etc.

Riffle:
  for N = 0 to 2  'move all words to the left for all 3 screens worth of WORDs
    MAX1A[N] = MAX2A[N] : MAX2A[N] = MAX3A[N] : MAX3A[N] = MAX4A[N] : MAX4A[N] = MAX5A[N] : MAX5A[N] = MAX6A[N]
    MAX1B[N] = MAX2B[N] : MAX2B[N] = MAX3B[N] : MAX3B[N] = MAX4B[N] : MAX4B[N] = MAX5B[N] : MAX5A[N] = MAX6B[N]
  next N

There must still be something I do not understand about array usage and syntax under PICBasicPro. Please point me in the right direction with regard to array variables.

Thank you to all who are patient with me and offer to help!
Bob Pigford
Newark, DE, USA