Page 1 of 1

V3 - Creating BYTE Array

Posted: Tue Apr 19, 2011 3:30 am
by Ron
Hi,

How can I create a byte array that is capable of going 1 - 3096?

Thanks

Ron

Re: V3 - Creating BYTE Array

Posted: Tue Apr 19, 2011 9:48 am
by Benj
Hello Ron,

AVR's, PIC24's, dsPIC's and ARM devices can have arrays up to any size providing they have enough ram to complete the array. PIC16 and PIC18 devices can have a maximum array size of 256 bytes due to their archetecture. You can create multiple arrays in a PIC and then use a overall switching technique to switch between arrays. However you would need a lot of arrays to cover the 3096, 13 to be exact.

Re: V3 - Creating BYTE Array

Posted: Tue Apr 19, 2011 4:34 pm
by Ron
Hi,

I am using 18F.....

How would I define an array 1 - 256?

Thank you,

Ron

Re: V3 - Creating BYTE Array

Posted: Tue Apr 19, 2011 4:51 pm
by Benj
Hello Ron,

In flowcode you would create a byte variable and after the variable name you would type square brackets containing the array size.

eg

byte0[256]
byte1[256]
byte2[256]
...

The bytes inside the array are addressed from 0 to the array size minus 1 in this case 255 giving you 256 memory locations.

eg

byte0[0] = variable.
variable = byte0[255]

You can then switch between the arrays by using divide and find the position in the array by using mod.

e.g.
address = 1350

array = address / 256
location = address mod 256

if (array = 0)
value = byte0[location]
if (array = 1)
value = byte1[location]
if (array = 2)
value = byte2[location]
...
etc

Re: V3 - Creating BYTE Array

Posted: Thu Apr 21, 2011 5:10 pm
by Ron
Hello Ben,

Thank you..... :)

Ron