Forum Discussion
Altera_Forum
Honored Contributor
15 years agoFlash Memory
Hello. I am using Altera DE2 Board with Flash (1Mb). I want to know how to store data into and read data from flash memory. For example, I want to store 1-10 into the flash. Then, I will read the num...
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- First of all init the flash device and possibly get extra info about the flash device, like block size:
flash_region *regions;
int numRegions;
int error = 0;
pFlashDevice = alt_flash_open_dev(FLASH_CONTROLLER_NAME);
if (pFlashDevice <= 0)
error = -1;
if (!error)
error = alt_epcs_flash_get_info(pFlashDevice, ®ions, &numRegions);
if (!error) {
flash_block_size = regions->block_size;
flash_max_addr = regions->region_size;
i am using cfi, is it the same? besides, my pflashdevice is <= 0. i dunno why. is it sth to do with reset vector as my reset vector is sdram. This is for writing any data to a previously erased area: int buf = { 1, 2,3,4,5,6,7,8,9,10 };
rv = alt_epcs_flash_write_block(pFlashDevice, block_address,
data_offset_inside_block , buf, 10);
why need rv when write data? Then, read back data with: alt_epcs_flash_read(pFlashDevice, addr, buf, len);
where is the data when we read it from the flash? like i want to print out the data. --- Quote End --- please help me with the ques in bold. thanks!