CAN rx/tx as regular Serial?

Status
Not open for further replies.

Fyod

Well-known member
This may be a n00bish question, but is there any way to get the CAN pair to work as a regular Serial pair, even if losing one of the other pairs?
 
For pins 3 and 4 on Teensy 3.1, no.

There are 3 real hardware serial ports. Their signals can be reassigned to certain other pins, but not 3 or 4. For example, Serial1 can alternately use pin 5 for TX1. Since this is a function of the way Freescale designed the chip, only a few alternate pins are available for specific ports.

The AltSoftSerial library can give you a 4th software-emulated serial port. It's not nearly as efficient as the hardware ports, especially Serial1 and Serial2 which have built-in FIFOs, but it does work well. Lower baud rates, like 9600 or less are best. It can work faster, but the cost is quite a bit of CPU usage. With AltSoftSerial, the default is receive on pin 20 and transmit on pin 21. That library does have a config file you can edit, to reassign to other pins. But only certain pins are possible: 5, 6, 9, 10, 22, 23 (because AltSoftSerial uses a timer which connects only to those pins). Pins 3 and 4 aren't on that list.
 
Thanks for the comprehensive reply, Paul.
I expected it wouldn't be possible, but nice to know the details.
The reason I ask is because I have 3/4 connected to my GSM board and a Molex connector and wanted to connect Serial via that connector, but that's OK.
 
Status
Not open for further replies.
Back
Top