Forum Discussion

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

SPI 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 connected them with the "loopback board".

My Code is:

//Write some data to the Slave
IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(SPI_SLAVE_BASE,0x04);
//Check the TRDY bit if data is written(TRDY=0 means it is writing and
//TRDY=1 again means the data was written)
trdyNumber=(IORD_ALTERA_AVALON_SPI_STATUS(SPI_SLAVE_BASE)& ALTERA_AVALON_SPI_STATUS_TRDY_MSK)>>6;
//Read from the register
int data=(IORD_ALTERA_AVALON_SPI_RXDATA(SPI_SLAVE_BASE)&0xFF);
printf("%d",data);

I also read the manuel for the SPI Core but it doesn't work. Can somebody help my with an exsample or give me an advice?

Regards

22 Replies