Question about serial ports

Status
Not open for further replies.

davestephans

New member
I didn't see where this was asked before, so forgive me if it has been.

I have a Teensy3.1, and I see it has 24 I/O pins. I need 23 I/O pins as outputs to represent a 23 bit BCD code, and also need to receive serial ASCII characters. I know I can use a breakout board, but I am trying to do it with the native 28 pins that are soldered already.

Can I use the Pin 0 Rx1 to receive the data, and then use Pin 1 as an output for another purpose...? Or will using the serial port mess up using TX1 pin 1 as just a regular output.

And if so, do I need to change something in my code to block it from trying to transmit on that pin...?

I absolutely love the Teensy 3.1....amazing chip for sure..!!

Thanks so much for your help!!
 
Download the datasheet for your part and look at control register 2 for the UART. I am looking at the datasheet for the Teensy 3.6 and it has separate enable bits for the TX and RX, so it looks promising that you can use the TX pin as general I/O.

Alternately a trick that has been used in the past is to set the break bit and send break characters when you want to set the TX pin low. When using this method for general I/O, the timing on the TX pin will be somewhat loose - meaning when you set the break bit, the pin may not go low immediately, and when you clear the break bit it may not go high immediately.
 
The Teensy 3.0/3.1/3.2 actually have 34 digital pins, with pins 24-33 brought out as solder pads underneath the Teensy. Six of those ten pins can also be used for analog input, two of the pins can be used for PWM outputs, and three for touch inputs. There are 2 additional analog input only pins that cannot be used for digital read or write.

You can solder wires to these pins to bring them out. There are some PCBs that also bring out the pins. I put some links for PCBs in this thread:

The pinout card that came with your 3.1 explains the layout.

If you use the pins underneath the Teensy, pin 33 on the Teensy 3.0/3.1 is special. It defaults to a non-maskable interrupt (active low) with a pullup resistor. When it's low on reset the MCU enters EZ Port mode, which basically turns the MK20 into a SPI flash chip. If you weren't using Teensyduino this might be how you'd upload a new program. The new bootloader chip (MK02/04) fixes the problem in Teensy 3.2.
 
Last edited:
PJRC discontinued Teensy 3.1 years ago. If you purchased that Teensy 3.1 recently, it's almost certainly a counterfeit. I'd advise staying far away from pin 33 in that case!
 
Status
Not open for further replies.
Back
Top