PDA

View Full Version : Storing data in Flash (Program) memory



MikeBZH
- 21st May 2009, 20:30
Hello,

I need to store two tables of data (32KB each) in the program memory.
These data will be read by the program when running.

I have found the way to store the data in EEPROM but not in the program memory.

Any help greatly appreciated.

The target is a 18F2685

MikeBZH

Darrel Taylor
- 21st May 2009, 21:58
Here's one way ...

Using EXT with Labels ...
http://www.picbasic.co.uk/forum/showthread.php?t=3891#LAB

hth,

MikeBZH
- 24th May 2009, 17:14
Thank you Darrel for your help.
I am going to try this

Mike BZH

Darrel Taylor
- 25th May 2009, 11:02
Yikes! I just realized you wanted 64k of data.

Do you have PBP 2.50?
With PBPL the READCODE statements can work above 64k, as long as the address variable is a LONG.

PBPW, can only READCODE up to the 64k barrier.

It's also possible to access the memory above 64k without using readcode if you don't have PBP 2.50, but it's a little trickier.
<br>

MikeBZH
- 26th May 2009, 06:03
Yes, I have PBP 2.50b.
So, it should work....

Michel

Darrel Taylor
- 26th May 2009, 07:41
Yes, I have PBP 2.50b.
So, it should work....
Yes it will. (using PBPL)

With the EXT example I pointed to earlier, all you need to change is ...
Offset VAR LONG

Even though Offset will never be greater than 65535, one of the parameters of the READCODE statement has to be a LONG.
Since DataTable is a constant, the Offset variable gets the duty.

I'm curious where the data is coming from.
Obviously you won't want to create 64k worth of DW statements.

Is the data in a file of some type?
<br>

MikeBZH
- 27th May 2009, 07:26
Dear Darrel,

Thank you again for your help
I will try all this as soon as I dig into the SW. I am currently testing and validating the hardware.
The data will be bytes, but don't be afraid, I will not type then one by one !
They will come from already existing tables in text format. So a simple select, copy and paste to the source file will do the job.

Best regards

MikeBZH

Darrel Taylor
- 28th May 2009, 01:19
The data will be bytes, but don't be afraid, I will not type then one by one !
They will come from already existing tables in text format. So a simple select, copy and paste to the source file will do the job.

Great! That'll make things easy.

Just one more suggestion then ...
Put the data in a separate .ASM file.

; make sure each line has an Even number of values.
DB 0xA4,0x95,0xB5,0xAA,0xA5,0x49,0x55,0x56,0xAD,0x55, 0x4A,0x56,0xB5,0xAA
DB 0xAD,0x56,0xD6,0x48,0x49,0x5B,0x6A,0xB5,0x55,0x4A, 0x4A,0xAD,0x6A,0xAA
DB 0x94,0xAA,0xAA,0xB5,0x5A,0x54,0xAA,0xB5,0xAA,0xB5, 0x55,0xAD,0x69,0x11
DB 0x25,0xB6,0xB5,0x55,0x55,0x25,0x2A,0xDA,0xD5,0x4A, 0x52,0xAA,0xAD,0x55
; ...
DB 0x6A,0xA9,0x25,0x2A,0xD5,0x6A,0xAA,0x95,0x55,0xAD, 0x55,0x55,0x55,0xAD
DB 0x6D,0x44,0x12,0xAD,0xDA,0xAA,0xAA,0x52,0x55,0x5B, 0x6A,0x94,0x94,0xAA
DB 0xB5,0x5A,0xA9,0x52,0xAD,0x6B,0x55,0x55,0x55,0x5B, 0x5B,0x50,0x82,0x5B

PBP has a limit to the number of lines in an ASM block.
That .ASM file can be included from the program by the assembler which doesn't have that limit.

DataByte VAR BYTE
Offset VAR LONG
DataTable1 CON EXT
DataTable2 CON EXT

'-----[The DATA table]--------------------------------------------------------
GOTO OverData ; Make sure data doesn't try to execute
ASM
DataTable1
#include "MyData.ASM"
EndTable1

DataTable2
#include "MyOtherData.ASM"
EndTable2
ENDASM
OverData:

'-----[Retrieve from DATA table]----------------------------------------------
Offset = 1
ReadCODE (DataTable1 + Offset), DataByte

LCDOUT $FE, 1, HEX2 DataByte," "

longpole001
- 4th March 2014, 05:17
Hi darrel , having a read of this thread , what is as the size limits and format requirements are for the asm file include
, I need to have about 2K of byte data for banner and font data

i have table of data , which are 240 bytes long with 64 lines per , taking up about 2k per banner

regards

Sheldon

Darrel Taylor
- 4th March 2014, 15:38
PBP3 increased the ASM block size from 4K to 64K of text.
So this thread doesn't really apply when it comes to how much code you can put in an ASM block.

The only real limitation now is how much code space is available in your chip.