I'm using the Reference design Generic Serial Flash Interface IP on Quartus Prime 18.1 to access Micron MT25QL512Mb flash memory.
Via NIOS processor, I able to read the memory data correctly in the single SPI mode by the function:
But when I'm trying to read the data in Quad SPI mode, I always got x"FFFF":
this is the Device's datasheet (page 37):
I would like to get some help here,
From your read_memory_quad function, it seems that you are configuring the IP but not the component. For instance, you set the IP to behave as Quad IO and 4-bytes adressing, but you also need to set the registers of the component. Or do you do this in another function prior to this one?
Actually, I think you must have done it at some point, because otherwise the QSPI's register bit 0 (addressing mode) would be 3-bytes (default value) while you have configured the IP as 4-bytes. And this is also true for the first, Single IO read function: in my opinion, it should not work (I may be mistaken).
On a side note, you might not have to do all the steps below if instead of FAST READ you use the 4 BYTE QUAD (INPUT) OUTPUT FAST READ command(s).
Putting that aside, to address any configuration or status register of a QSPI with the GSFI IP, you need to use the CSR register 0x7. There is a number of fields in this register that you need to configure depending on the command you want to use:
1) you need to to a Write Enable to modify configuration register (Opcode = 0x06). You can IOWR 0x06 to register 7, for this one.
2) you need to write the configuration register itself, either with WRITE VOLATILE (Opcode = 0x81) or WRITE NON VOLATILE (Opcode = 0xB1). You need to set the number of data bytes to either 1 or 2, depending on the command, in register 7. You put the data you want to write in the 0xA/0xB registers of the IP.
3) (optionnally) if you use WRITE NON VOLATILE, the datasheet states that you need to poll the STATUS REGISTER or FLAG STATUS REGISTER until completion. That means you need to change register 7 once more according to the READ (FLAG) STATUS REGISTER Opcode. The read back data will be in the 0xC/0xD registers.
Hope it can help to solve your problem!