code to flash and data to EEPROM

Hi to all,

I'm working on a dev with groups of data which I will use one by one.
Let's say it's a game with 5 levels. I have data to define each level, but at a time I use only data from one level.

My idea is to burn the data of the levels in EEPROM. Then check which level I want to use, copy the data for this level into RAM, then play. At end of level 1, load level 2 in RAM and so on.

I know I can use external module to "burn" the EEPROM, and then use the IDE to store my program in the flash. So a two step process. I know also I can create a code doing a lot of EEPROM.write to store the data. So load this code in flash with the IDE, run it, then load the final code. So a three step process.

But is there a way to directly put the data in the code with instruction telling the IDE to store the code part in flash and the data part in EEPROM (at predefined locations)? (so a one step process)

Thanks a lot
PL

PS: I can't use SD card or any other external system.

Hi there!

I found a good reference on how to use the EEPROM Library. Maybe it will help!

bos1714:
Hi there!

I found a good reference on how to use the EEPROM Library. Maybe it will help!

Don't think it help.
I know the EEPROM lib but to use it you must write code.
Let's say I write:
EEPROM.write(0,'Y');
EEPROM.write(1,'E');
EEPROM.write(2,'S');

EEPROM.write(10,'N');
EEPROM.write(11,'O');
EEPROM.write(12,'Y!);

Then I do:
if (flag = 1)
{
start =0;
}
else
{
start = 10
}

Then I read with
for (x 0 to 3)
EEPROM.read(x+start)

If flag=1 I will get "YES" else I will get "NO!"
The problem is that, i that case, to "store" "YES" and "NO!" I used EEPROM.write which use space in my flash.

The question is "how can I store YES and NO! in ROM without use of EEPOM.write, knowing I want that only one time

Thanks
PL

Does the level data have to be stored in EEPROM? What’s wrong with storing it in program (flash) memory? That seems like a more logical place to put it to me.

christop:
Does the level data have to be stored in EEPROM? What's wrong with storing it in program (flash) memory? That seems like a more logical place to put it to me.

Maybe. Actually even the dev is at its beginning, we start to a lot of space for the code. So i'm afraid of not having enough free space in the flash. But putting data in flash can be a good option (an easier!)

Thanks

Could you perhaps use another Arduino to store the additional data? I remember you saying that you cannot use an SD card, but maybe another microcontroller could act as an SD card.

The ATMega328p in the Uno has 32768 bytes of flash memory and only 1024 bytes of EEPROM, so you're more likely to run out of EEPROM before you run out of flash memory (unless your program is close to filling up the flash memory).

Putting the level data into flash definitely sounds like the right approach to me, if at all possible. That way you don't even need to copy it to ram, just read it out of progmem directly.

On the other hand, maybe you'd want to burn the level data to an external EEPROM (eg, AT24 series); there's a really cheap programmer you can get on ebay/etc that is based on I think CH341 (not the same as CH340) that (if you can locate the english version of the software or read chinese) can write and read AT24 EEPROMs. This has the downside of being a two-step process and using extra hardware - but depending on how much level data you have, it may be the only viable option.

On the third hand, there are larger AVR microcontrollers - 1284p (with 128k flash 16k ram, used in some 3rd party boards, excellent part), or 2560 (256k flash 8k ram, used in mega2560) - depending on your needs, these may be more appropriate.

Don't think it help.
I know the EEPROM lib but to use it you must write code.
Let's say I write:
EEPROM.write(0,'Y');
EEPROM.write(1,'E');
EEPROM.write(2,'S');

or you could use EEPROM.put() to save the string all at once or even better, put the data in a struct and save the struct all at once.

Retrieve the data using EEPROM.get()

DrAzzy:
Putting the level data into flash definitely sounds like the right approach to me, if at all possible. That way you don’t even need to copy it to ram, just read it out of progmem directly.

On the other hand, maybe you’d want to burn the level data to an external EEPROM (eg, AT24 series); there’s a really cheap programmer you can get on ebay/etc that is based on I think CH341 (not the same as CH340) that (if you can locate the english version of the software or read chinese) can write and read AT24 EEPROMs. This has the downside of being a two-step process and using extra hardware - but depending on how much level data you have, it may be the only viable option.

On the third hand, there are larger AVR microcontrollers - 1284p (with 128k flash 16k ram, used in some 3rd party boards, excellent part), or 2560 (256k flash 8k ram, used in mega2560) - depending on your needs, these may be more appropriate.

Thanks very much.
I stay with the flash approach but I’ll have also a look at the other options (even if my chinese is… well… )

Regards