Forum Discussion
Altera_Forum
Honored Contributor
17 years agoHow to write in EPCS
Hello, I am a newbie with Nios II. I'm doing a robotic project with a Cyclone and an EPCS4 flash memory. I've added an EPCS controller in my SOPC Builder system. I has to read...
Altera_Forum
Honored Contributor
17 years agoHi there,
If your project is using the reduced drivers option you will have to define the symbol ALT_USE_EPCS_FLASH in the system library properties. Then include the header file <altera_avalon_epcs_flash_controller.h> in your source code. Here's a snippet from my code as a starter for ten: # include <altera_avalon_epcs_flash_controller.h># include <sys\alt_flash.h> static alt_flash_fd *p_epcs_fd; static flash_region *p_epcs_reg_info; static int num_epcs_regs; void epcs_open(void) { <blockquote>p_epcs_fd=alt_flash_open_dev(EPCS_CONTROLLER_NAME); <blockquote>// Get pointer to flash info structure</blockquote> alt_epcs_flash_get_info(p_epcs_fd, &p_epcs_reg_info, &num_epcs_regs); <blockquote>// Verify flash details</blockquote></blockquote>} You could try compiliing and running this, then display the region info to see if it makes sense. I then go on to use the functions alt_epcs_flash_erase_block, alt_epcs_flash_write_block and alt_epcs_flash_read with p_epcs_fd as the first argument in each case. I hope this helps. Have fun.