Altera_Forum
Honored Contributor
19 years agoFlash device driver
Hi everybody.
I am developing a solution using the Nios Development Kit Cyclone Edition that is fitted with an EP1C20 and an AM29LV065D 8MB flash chip. I am using the flash and successfully writing and reading data to and from it. My problem is that sometimes writing data to it can take very long. I use the standard functions provided by the NIOS II cpu, and this is the only way of accessing the flash that I know of. I service up to 30 UARTs as well as comms with a server in a single threaded fashion, obviously using statemachines. The problem comes when wirting to the flash on behalf of one of the UARTs, and it takes up to 2500ms, I miss other events that occur in the mean time as I cannot service the other state machines. I have written a little "torture test" procedure to make sure about my facts, and what I have done is to sit in a loop and write 0xAA to address 0x5A0000 -> 0x5AFFFF, then write 0x55 to 0x5A0000 -> 0x5AFFFF. Once this is done, I increment my address by 0x10000 and continue doing this until I get to 0x790000, where I reset my address to 0x5A0000. Each of the write operations takes around 2500ms which then confirms my suspition that the flash is taking up the time. The procedure to write is as explained in the NIOS II Software Handbook. flashdevid = alt_flash_open_dev(flash_dev_name);record my millisecond timer counter here
alt_write_flash(flashdevid,flashaddr,&temp_flashspace[0],0xffff);
record my millisecond counter again and take the difference.
this then ensures that i measure only the time that it takes to write the data.
alt_flash_close_dev(flashdevid); I need to be able to give the data to a procedure that then writes it for me (like an ISR) and I can then poll its status to see if it is finished. This way I'll be able to continue servicing the rest of my applications statemachines. Please provide any comments or help. Regards, Tyrone