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

Thread: Selecting Alternative Functions of a Pin

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    15

    Selecting Alternative Functions of a Pin

    Hello

    I am drawing a PCB that uses a Teensy 3.6 but I have not yet got the physical board to do the tests.

    I need Serial 1 and also SPI1 working but SPI1 uses pins 0 and 1, which are also used by Serial1. I think the Serial 1 pins can move up to Pin 27 and Pin 26 but I'm not sure how to do it or even if it can be done.

    Would something like this work?

    Code:
    *portConfigRegister(0)  = PORT_PCR_MUX(2);	// Pin 0  >> SPI1_MOSI
    *portConfigRegister(1)  = PORT_PCR_MUX(2);	// Pin 1  >> SPI1_MISO
    *portConfigRegister(26) = PORT_PCR_MUX(3);	// Pin 26 >> Serial1_TX
    *portConfigRegister(27) = PORT_PCR_MUX(3);	// Pin 27 >> Serial1_RX
    For basic use, is it necessary to configure pin pull-up, pin filter and that stuff?

    Code:
    *portConfigRegister(X) = PORT_PCR_MUX(Y) ) | PORT_PCR_PFE;
    Is there any tutorial for beginners on how to configure the alternative functions of the pins?

    Thanks and sorry for my awful English.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,115
    Quote Originally Posted by FAlameda View Post
    I think the Serial 1 pins can move up to Pin 27 and Pin 26 but I'm not sure how to do it or even if it can be done.
    Serial1.setTX(26);
    Serial1.setRX(27);

    Detailed documentation here:

    https://www.pjrc.com/teensy/td_uart.html

  3. #3
    Senior Member
    Join Date
    Dec 2016
    Posts
    607
    you could also use the alternate SPI1 pins 5,20,21 as well

    dont forget to *.begin AFTER you set the pins

  4. #4
    Senior Member defragster's Avatar
    Join Date
    Feb 2015
    Posts
    4,655
    Quote Originally Posted by tonton81 View Post
    you could also use the alternate SPI1 pins 5,20,21 as well

    dont forget to *.begin AFTER you set the pins
    That would be a good thing to demonstrate on the PJRC page for proper function as one could wrongly intuit it as sensible to have it work the other way.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,115
    The latest versions of SPI, Wire and Serial# are all designed to allow changing the pins before or after you call begin().

    Of course, if you call something like SD.begin(), you must configure the pins before, since it actually does communication on the pins. Hopefully that's obvious? (and it's in many of the examples....)

  6. #6
    Senior Member defragster's Avatar
    Join Date
    Feb 2015
    Posts
    4,655
    Quote Originally Posted by PaulStoffregen View Post
    The latest versions of SPI, Wire and Serial# are all designed to allow changing the pins before or after you call begin().

    Of course, if you call something like SD.begin(), you must configure the pins before, since it actually does communication on the pins. Hopefully that's obvious? (and it's in many of the examples....)
    Nice .......

Posting Permissions

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