Creating Constant value Flash Memory Tables of different data sizes
A standard flash memory table will create its constant elements depending on their size. For example, the table below will create different sizes in flash memory and they will not be able to be accessed by an index correctly because each value will occupy a different amount of flash memory:
Dim FlashTable as Flash = 0, 1, 1024, 123456, 1234567890
In order to counteract this and always produce the same size elements in flash memory, the directives Flash8, Flash16, Flash24, Flash24, Flash32 or FlashF can use used. These are the same as the directives: Code8, Code16, Code24, Code24, Code32 and CodeF, but use a different name because the internal program memory used to be called ‘Code’ memory, but is now called ‘Flash’ memory within datasheets.
1.) Create a flash memory ASCII character table:
Dim FlashString as Flash8 = "Hello Word, How are you?", 0
2.) Create a flash memory table consisting of 8-bit constant values only:
Dim FlashTable as Flash8 = 0, 1, 1024, 123456, 1234567890
In the above table, the longer values will all be truncated to fit 8-bits.
3.) Create a flash memory table consisting of 16-bit constant values only:
Dim FlashTable as Flash16 = 0, 1, 1024, 123456, 1234567890
In the above table, the longer values will all be truncated to fit 16-bits and the shorter values will be padded to also fit 16-bits.
4). Create a flash memory table consisting of 24-bit constant values only:
Dim FlashTable as Flash24 = 0, 1, 1024, 123456, 1234567890
In the above table, the longer values will all be truncated to fit 24-bits and the shorter values will be padded to also fit 24-bits.
5). Create a flash memory table consisting of 32-bit constant values only:
Dim FlashTable as Flash32 = 0, 1, 1024, 123456, 1234567890
In the above table, the longer values will all be truncated to fit 32-bits and the shorter values will be padded to also fit 32-bits.
6). Create a flash memory table consisting of 32-bit floating point constant values only:
Dim FlashTable as FlashF = 0, 3.14, 1024.9, 123456, 1234567
In the above table, the integer values will all be converted into 32-bit floating point constants. Unlike the original Cdata directive, the Dim as Flash directives can be placed anywhere in the BASIC program’s listing because they do not reside in that position within the flash memory. They are automatically placed in the most appropriate place within the device for quick and easy access, and out f the way of the program’s flow. Thus making a program smaller and faster still!