FlexSerial Problems on Teensy 4.1

ForbinOne

New member
I am trying to solve the Flexserial library usage on a Teensy 4.1 with pins 2,3,4,5 as serial outputs, to communicate at 9600 BAUD with an APC220 connected on either of the four pins.

I am getting question marks on the receiving APC220 which implies that there is a baud rate issue. If I connect serial1 then the text is clear and the link radio link functions.

This is my code

#include <FlexIO_t4.h>
#include <FlexSerial.h>

#define TX_PIN 3
#define TX_FLEX_IO_INDEX 0
#define TX_FLEX_IO_TIMER 0
#define TX_FLEX_IO_SHIFTER 0
#define TX_PIN2 4
#define TX_FLEX_IO_INDEX2 0
#define TX_FLEX_IO_TIMER2 1
#define TX_FLEX_IO_SHIFTER2 1
FlexSerial SerialFlex(-1, TX_PIN, -1, -1, -1, TX_FLEX_IO_INDEX, TX_FLEX_IO_TIMER, TX_FLEX_IO_SHIFTER);
FlexSerial SerialFlex2(-1, TX_PIN2, -1, -1, -1, TX_FLEX_IO_INDEX2, TX_FLEX_IO_TIMER2, TX_FLEX_IO_SHIFTER2);

void setup() {
pinMode(13, OUTPUT);
while (!Serial && millis() < 4000);
Serial.begin(9600);

Serial1.begin(9600);

delay(500);
SerialFlex.begin(9600);
SerialFlex2.begin(9600);
}


void loop()

{


Serial.println ("Line Transmitted");

Serial1.println("Sending A Transmission on Serial1");

SerialFlex.print("Sending A Transmission on Flex");
SerialFlex2.print("Sending A Transmission on Flex 2");


delay(1000);


}
 
In case anyone's still watching this old thread, it seems FlexSerial simply can't do 9600 baud. Even with the FlexIO clock configured to the slowest possible setting, the 8 bit divider just doesn't allow for baud rates under 14706. I recently spent a couple days trying to make FlexSerial use a 16 bit timer for baud rate, or use another timer as a prescaler. Never did find a way to make it work. I also tried reaching out to people at NXP, who haven't replied. Best answer possible at this time is FlexSerial simply can't do slower baud rates.
 
all the wires can really matter. The ground wires in particular can play a large role.

As a general rule of thumb, you usually want motors or motor controllers which power them to connect as directly to the main power source as possible using heavy gauge wires. Typically you would avoid connecting other devices like Teensy to those same wires which are carryin
Looks like @KurtE tried that as well: https://forum.pjrc.com/index.php?threads/flexserial-on-a-teensy-4-1.70976/
 
Back
Top