Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
903 Views

configuring SPI on SOPC

hello, I am trying to configure DE2 board as a Master and connect device(s) to it via SPI. 

DE2 -------> Device(s) 

 

In SOPC, do I include "SPI (3 wire serial)" from the library or "Avalon-ST Serial Peripheral Interface"? 

 

Also do I need to use the expansion headers (GPIO0, GPIO1) and connect MISO,MOSI,SS,SCK to any pins? Because I don't see a SPI port on DE2 board. 

 

I just need to know how to configure SPI and which pins to use to connect to device(s). 

 

Lastly, are there any example C codes for sending/receiving data via SPI? 

 

Thank you very much
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
19 Views

Hello, 

 

I happen to be doing the same thing but am using Qsys instead of SOPC. To answer your questions: 

 

1. Yes I used the SPI (3 Wire) interface. 

2. I used pins on the GPIO_0 (JP1) connector to connect the SS, MISO, MOSI and SCLK pins of the external device. Since MISO is an input (for the Nios II) and MOSI in an output, you need to rename DE2.qpf pin assignments so that they are no long GPIO_0[n] - since signals in the same bundle cannot be inputs and outputs. Otherwise simply assign the Nios exports from the SPI to pins on the GPIO_0[n] pins and then physically connect these pins to the correct pins on the device. 

3. I found the function on this page somewhat useful - http://www.alterawiki.com/wiki/spi_core - you don't need to use the interrupts, just the bit that calls the HAL function alt_avalon_spi_command(). This driver is very rudimentary by the way - trying to get my students to build on it a bit in the lab.
Reply