Forum Discussion
Altera_Forum
Honored Contributor
14 years agoSPI Problems
Hi, I'm trying to get handle with the SPI on a Nios II Core but I don't get it. I have a SPI master and a SPI Slave that I can try to transmit some data from the master to the slave. I connecte...
Altera_Forum
Honored Contributor
14 years agoTry changing the wait completion loop this way:
do{
IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,countTMT & 0x01);
usleep(50000);
countTMT++;
status = IORD_ALTERA_AVALON_SPI_STATUS(SPI_MASTER_BASE);
} while( ((status & ALTERA_AVALON_SPI_STATUS_TMT_MSK) == 0)
|| ((status & ALTERA_AVALON_SPI_STATUS_TRDY_MSK) == 0) );
Also check if timing parameters (clock polarity and phase) match master and slave. Your problem can be possibly due to the fact that slave is missing a clock pulse, then the rx word would be completed only on the first clock pulse of next tx word, thus leading to shifted results.