Forum Discussion
Altera_Forum
Honored Contributor
14 years agoSPI read example
Hello,
I need an example of the read transaction with the response. User Guide "Embedded Peripherals IP" has only write example. I tried the following transaction with no success: the packet format I pass: 0x7a, 0x7c, 0x0, 0x14, 0x0, 0x0, 0x4, 0x0, 0x0, 0x60, 0x7b, 0x8 That means read 4 bytes from address 0x00006008. But the response is always IDLE byte (0x4a), i.e. no data is returned. 2) Write transaction is successful and I get a proper response from the SPI, but after a Read transaction the Write always fails. :(2 Replies
- Altera_Forum
Honored Contributor
Hi sercher,
maybe I misunderstood but, are you trying to read from SPI without write on it? Remember that if the niosII is the master of the SPI transaction you have to write N bytes on the MOSI pin even if you wanna read N bytes. This because the slave is essentially a shift register and if you don't do this, it don't reply. Perhaps is this your problem? Try to use the alt_avalon_spi_command() function: this one first write X bytes and then read Y bytes (during this last operation it send 0 to the slave). I agree that if you have only to read, this is an oversized function, but it's a first step... - Altera_Forum
Honored Contributor
Sorry, the problem was not linked with SPI, but with specific FPGA memory area. Other memory addresses work good for read.