V3 - Creating BYTE Array

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

V3 - Creating BYTE Array

Postby Ron » Tue Apr 19, 2011 3:30 am

Hi,

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

Thanks

Ron

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: V3 - Creating BYTE Array

Postby Benj » Tue Apr 19, 2011 9:48 am

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.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

Re: V3 - Creating BYTE Array

Postby Ron » Tue Apr 19, 2011 4:34 pm

Hi,

I am using 18F.....

How would I define an array 1 - 256?

Thank you,

Ron

User avatar
Benj
Matrix Staff
Posts: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: V3 - Creating BYTE Array

Postby Benj » Tue Apr 19, 2011 4:51 pm

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
These users thanked the author Benj for the post:
George_B (Sat Feb 13, 2016 8:55 pm)
Rating: 5.26%
 

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

Re: V3 - Creating BYTE Array

Postby Ron » Thu Apr 21, 2011 5:10 pm

Hello Ben,

Thank you..... :)

Ron