Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

SPI RX problems

Hi

I am trying to receive data via SPI on the Nios II using a Cyclone II. The Nios is the slave and the SPI master transmits data at 2MHz.

I have tested transmitting data from the Nios to the SPI master and that worked fine.

I have written the following code to test the receiving of data:

//SPI RX

while (1) {

//clears the status register

IOWR_ALTERA_AVALON_SPI_STATUS(SPI_0_BASE, 0);

//if new byte arrived via SPI

if ((IORD_ALTERA_AVALON_SPI_STATUS(SPI_0_BASE) & ALTERA_AVALON_SPI_STATUS_RRDY_MSK) == 1){

//read the byte and print it to screen

printf("%x\n", (IORD_ALTERA_AVALON_SPI_RXDATA(SPI_0_BASE) & 0x0FF));

}

}

The IF statement never becomes true. I have removed the IF and read the RXDATA. The data that the SPI master transmitted is correctly received in the RXDATA buffer but the the RRDY bit never goes high.

Does anyone have any idea why this not working? Am I doing it correctly, because I used a similar approach to TX data and that worked.

Thank you

Eric

13 Replies