Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20777 Discussions

Problem Communication Between Master SPI device and Slave SPI

Altera_Forum
Honored Contributor II
922 Views

Hi, I am trying to make Master(DE2-115) and Slave(DE0) communicate with each other. However, I have faced some problems. 

 

Questions: 

1) My slave device is generating a set of data. Once the chip selecte is selected, the data will be sending via MISO from the slave and receive MISO to the Master device. After that, I want to copy the received data and send out via MOSI from Master device. My question is, how to save the data from receive MISO to MOSI in the master device? 

 

2) I know that slave selecte is active low and I am trying to select 8 channels from the slave which it is generating different set of data. This is my code below which is programed in the Master device: 

 

 

slave = ((slave << 1) + 1)-256; 

IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(SPI_BASE, slave); 

IOWR_ALTERA_AVALON_SPI_CONTROL(SPI_BASE, ALTERA_AVALON_SPI_CONTROL_SSO_MSK); 

 

 

which it is trying to do is WRITE 0xFE (1111 1110) represent 8 channels but the 1st bit is 0 and the 0 will be shifting every time it run into the loop. My question is, is this the way to control the chip select? 

 

*My salve ss_n is not selected and not sending any data out when I use the code above.  

 

Any help will be appreciated. 

Thanks and hope that you guys can help me figure these out.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
210 Views

Although ss_n is an active-low signal, bits in slave select register must be set high in order to assert (low) the corresponding signal. 

Moreover, pay attention to the fact that the slave device will send data only upon master request. So, the slave must preload data in tx register: but this will not be transmitted immediately: it will only when the master asserts ss_n and transmit some data (useful or dummy data) to the slave. With spi you always have two concurrent transfers: while MOSI is sending data from Master to Slave, MISO is sending from S to M
0 Kudos
Reply