Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Changing MISO pin using SPIFIFO

  1. #1

    Changing MISO pin using SPIFIFO

    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.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    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...)

  3. #3
    Thanks for the reply. Looks like SPI libraries are a continuous evolution to keep up with the hardware.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    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...

  5. #5
    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).

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quote Originally Posted by LAtimes View Post
    turns out I need to call both SPI.setMISO and SPCR.setMISO
    Any chance you could give 1.41-beta2 a try. This is supposed to be fixed now.

  7. #7
    Good news. 1.41 beta2 fixes it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts