SPI


Guest linobi

Recommended Posts

Hi everyone!

AVR8 is so cool! It's amazing how can you run an Arduino inside a FPGA. Right now I'm working in a project with it and I need some help.

I'm trying to use a nordic radio that communicates via SPI, but I'm still unsure on how to pull the SPI port from the Papilo 250K core.

My original code works in a regular Arduino Board with the IDE version 0022 and make use of the integrated SPI library. When I tried to compile the same code with the Papilo IDE the SPI library shipped with it didn't seem to be the same, so I replaced it with the library files from the standard Arduino IDE 0022 and then compiled without errors.

However, the stuff simply doesn't work. I review the uSD-wing example in the Papilo IDE and there I notice some lines of code noted to do something with the SPI, something like declaring where it is or something like that, I'm not sure if I've got to do something similar or if the SPI library from newer Arduino IDE is not yet fully compatible with the AVR8 core and then all my effort are futile :(

Any input will be greatly appreciated

Regards

Link to comment
Share on other sites

Guest b3457m0d3

hi linobi!  i too am trying something similar.  my quandary is more of the shield converting persuasion, though i require a similar answer.  on the usb host shield mini, i know what pins to wire out from, but not what to wire into the papilio 250k board.  http://papilio.cc/index.php?n=Papilio.CustomAVR8UserCore addresses pin  juggling.  Maybe you can find your answer there?  my problem seems to remain unsolved in how to actually port the usb host libraries, or if i even have to.. anyway, hope this helps.

Link to comment
Share on other sites

Hey guys,

This is great! I'm more then happy to help you guys work through your issues and get you up and running with your projects on the AVR8 with SPI.

I'm trying to use a nordic radio that communicates via SPI, but I'm  still unsure on how to pull the SPI port from the Papilo 250K core.

First of all, the SPI core does need to know which pins it is supposed to connect to on the Papilio. It is pretty straightforward how you would go about doing this. You want to be using the Papilio-Arduino IDE for this.

For a more visual summary check out the Papilio Pinout Introduction page.

If you look at the Papilio you will see that it has Row A-C, each row has pins marked as 0-16. There are several options available to reference a pin. As an example lets say we need to connect an SPI device to the following pins:

  • MOSI = B12
  • MISO = B13
  • SCK = B15

When I say B12 we are talking about the 13th pin (starts at 0) on row B. There are three ways we can reference those pins, you can choose whichever is most convenient for you:

  • You can use row terminology, so you could simply refer to the MOSI pin as B12.
  • You can break each row into 8 bit sections by calling the lower 8 bits AL, BL, or CL and the upper 8 bits AH, BH, or CH. So for our MOSI pin we would reference it as BH4.
  • You can use standard Arduino terminology of just a number. Row A starts  at 0 and goes through 15, Row B starts at 16 and goes through 31, Row C  starts at 32 and goes through 47. So with this option MOSI at B12 would  be 28.

Once you understand the options to reference the pins you just need to tell the AVR8 where you want the SPI pins to connect. You need to add the following to your setup function:



void setup() {
  //Move the SPI pins to the desired Wing Slot
  SPI1_mosi_LOC=B12; 
  SPI1_miso_LOC=B13; 
  SPI1_sck_LOC=B15; 
 
  Serial.begin(9600);
}

OR


 
void setup() {
    //Move the SPI pins to the desired Wing Slot
    SPI1_mosi_LOC=BH4; 
    SPI1_miso_LOC=BH5; 
    SPI1_sck_LOC=BH7; 
   
    Serial.begin(9600);
  }

OR


 
void setup() {
    //Move the SPI pins to the desired Wing Slot
    SPI1_mosi_LOC=28; 
    SPI1_miso_LOC=29; 
    SPI1_sck_LOC=31; 
   
    Serial.begin(9600);
  }

Once you tell the SPI pins where they need to be connected you should be able to use SPI code like usual.

NOTE: There seems to be something weird going on with putting the SPI pins on the AH slot, if you are having problems please try a different slot until I can debug what is going on. I suspect something else is connected to those pins and is causing a conflict.

Link to comment
Share on other sites

  • 2 years later...

Hello Everybody

 

I am working on a project that involves the use of SPI communication from the papllion fpga to a slave device(an led strand),So my question is, will I be able to use the SPI library for avr8 soft processor ( I noticed the the VHDL files for the softprocessor do not have an SPI module included in it, but they do have the UART module, MUX ,Ports , custom core etc). 

 

If yes, then how can it be done?.

 

Any help would be greatly  appreciated, I need this for my school project.

 

Thanks!!

Link to comment
Share on other sites

Hello Everybody

 

I am working on a project that involves the use of SPI communication from the papllion fpga to a slave device(an led strand),So my question is, will I be able to use the SPI library for avr8 soft processor ( I noticed the the VHDL files for the softprocessor do not have an SPI module included in it, but they do have the UART module, MUX ,Ports , custom core etc). 

 

If yes, then how can it be done?.

 

Any help would be greatly  appreciated, I need this for my school project.

 

Thanks!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.