I have run into a problem on a P24FJ64GA002 MCU when trying to use a for loop to run through a constant array, e.g.
Code: Select all
dim name as char[16]
i as byte
const given_name as char[16] = ("J", "O", "H", "N", "S", "M", "I", "T", "H")
''' Doesn't work
for i = 0 to 8
name[i] = given_name[i] ''result: name[i] = ÿ, or ò, or â, etc...
next i
''' Does work
name[0] = given_name[0]
name[1] = given_name[1]
''' ...
name[8] = given_name[8]
Notes:
- Assigning non-constant arrays to non-constant arrays does work.
- Manually assigning const array to non-const array does work.
- If the const to non-const assignment for loop is high up enough in the code, the optimizer will automatically assign the correct values -- but if it is far enough down in the code it will not and will produce garbage assignments again.
- I have tried using a loop using pointers and their values, but there is a bevy of errors associated with that too (the IDE shows the correct 'value' that is being pointed to, but the address is pointing to ~0x8000 above where the correct address is at and I am unable to access the correct value).
If there are any workarounds that will allow me to assign const array values to non-const arrays without having to manually type out hundreds of assignment lines please let me know. I have tried just about everything to make this work and I am not finding any success.
Thank you for your time.