Changing MISO pin using SPIFIFO

Status
Not open for further replies.

LAtimes

Well-known member
I want to use pin 39 for MISO with the Ethernet library and a WIZ80. Using a Teensy 3.5, so it uses SPIFIFO. I tried SPI.setMISO but that didn't work (leaves pin12 also set to MISO via SPIFIFO.begin, which calls SPCR.enable_pins). To get it to work, I had to call SPCR.setMISO.

Note: SPI.setMISO works for pin 8, but not 39. I think it is just luck as to which pin the SPI module uses if multiple pins are enabled for MISO.

Is this the right way to do it (SPCR.setMISO)? Using Teensyduino 1.40.
 
Looks like you need to use the SPCR calls to do this. As the SPI calls set their own (internal to library) state, where as the SPCR calls set a different state variable... Maybe we should have the SPI calls call through to also set the SPCR values...

Or maybe the SPIFIFO should work like my SPIN library which uses SPI library to do the main work (Which also is setup for SPI1 and SPI2 as well...)
 
Thanks for the reply. Looks like SPI libraries are a continuous evolution to keep up with the hardware.
 
Yes - As I mentioned, I wish that SPIFIFO was derived from the SPI library and not a core file.

Then probably most of it goes away... Like setting which pin is a valid CS pin. You can simply call the SPI library function for this... So you don't have to replicate all of the testing for which pin is valid, which changes as we add new hardware.

Wonder how hard it would be to update SPIFIFO to be a library... So far the only dependency I see is avr_emulation.cpp includes it to define it's static variables.

It should be easy to add the same support into SPIN as I already have members helper functions for handling queue like: waitFifoNotFull, waitFifoEmpty...

But then again SPIN is not something that ships with Teensyduino...
 
After a little more experimentation, it turns out I need to call both SPI.setMISO and SPCR.setMISO to ensure that the default pin 12 is turned off (both SPI.begin and SPIFIFO.begin set the pins).
 
Status
Not open for further replies.
Back
Top