Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Storing values after Flash programming

Altera_Forum
Honored Contributor II
1,742 Views

Hi All, 

 

As i am nearing end of my product development, i am coming across a requirement which i dont know how to go about, 

 

[LIST] I want to add/change values using keypad/LCD (which are already in place) into the device when its working in standalone. I guess its clear, i want to do what these Meters in market do, store some user parameters and it gets recalled on subsequent power up also.  

[/LIST] 

 

Is this possible, if so give any clues or procedure to try out.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
584 Views

Flash is arranged as sectors. If you have not used the entire flash, then you can store user data in one or more other flash locations. If the user area needs to change, then you can erase just one sector. 

 

There are many improvements on this basic idea, eg., if there is more space in a sector than your user data will use, you can create a linked list in flash of user parameters, with the last entry in the list being the entry to use. When new data is entered, the link list gets updated to void the last entry, and point to the new entry. When an entire sector is used (contains old entries), you can erase it and start again. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
584 Views

Hi Dave, 

 

Thanks for the reply, i am pretty new to FPGA's.... Have started using and learning the same along. Can u make it simple for me to understand please ?  

 

I am rite now making a meter which shows Voltage ! so the user might want to set, say the frequency in this place. so he will change it in the frequency menu, the system will work with that value till power down, but on subsequent power up, the frequency set earlier will be reset to default value. I want to store that info which is getting lost.  

 

I am using a Quartus model + NIOS II for display/keypad/sram interface. 

 

Thanks and Regards 

San
0 Kudos
Altera_Forum
Honored Contributor II
584 Views

Hi San, 

 

--- Quote Start ---  

 

Can u make it simple for me to understand please ?  

 

--- Quote End ---  

I'll try. Here's what your code needs to be able to do: 

 

1) Processor boots. 

2) Processor looks in the user area in flash for the user configured frequency value. If it finds it, it uses it. If there is no user value, it uses a default. 

3) If the user enters a new frequency value, the processor writes it to flash. 

 

Flash memory starts out set to 0xFF. Lets say your frequency value is two bytes, i.e., a 16-bit value. In your C-code you can have something like this; 

 

int16_t *user_flash = 0x12340000; /* Start of user flash area */ int16_t frequency = -1; uint16_t user_len = 0x100; /* Number of frequency values per sector */ uint16_t i; /* Seach for a value that is not 0xFFFF = -1 */ for (i = 0; i < user_len; i++) { frequency = user_flash; if (frequency != -1) break; } if (frequency == -1) { /* No user value specified, so use default */ frequency = 123; } .... This is an extremely simple example, so that you get the concept. Now that you know what you are looking for, try and look at actual implementations. 

 

If you were using a bootloader like U-Boot, then this type of variable is saved in the environment section in flash.  

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
584 Views

Hey all, 

 

Its been a while and i have not successfully saved data in runtime, infact i was held up with other modules. I have some doubt. SOrry for the doubt, I am using a EPCS 16 so it has 2 MByte of memory, right ? my NIOS shows only 2048 byte which is 2 KByte !! I am confused. How to find free space in EPCS. i am sure that am not using even 1 MB of memory on it. Need help soon !!
0 Kudos
Reply