Forum Discussion
Altera_Forum
Honored Contributor
19 years agoSPI 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 ...
Altera_Forum
Honored Contributor
19 years agoThere were 2 problems:
1.) The IF statement was wrong... (stupid mistake) 2.) Clearing the Status Register every time erased some of the RRDY bits. Here is the working test code: while (1){ if (IORD_ALTERA_AVALON_SPI_STATUS(SPI_0_BASE) & ALTERA_AVALON_SPI_STATUS_RRDY_MSK){ //read the byte and print it to screen printf("%02x\n", (IORD_ALTERA_AVALON_SPI_RXDATA(SPI_0_BASE) & 0x0FF)); //clears the status register IOWR_ALTERA_AVALON_SPI_STATUS(SPI_0_BASE, 0); } }