3.2 Serial question

jim lee

Well-known member
If I call..
C++:
Serial1.begin(9600);
Will it actually run at that slow of a speed? Or will it go to a faster limit?

Thanks!

-jim lee
 
Serial1 is a UART and it will be set to precisely that speed (as best the clocks allow) or it would fail to match the other UART's timing

Not to be confused with Teensy's native USB Serial that will require (for compatibility), but ignore the baud rate and will connect and transfer at the Host's possible speed. On Teensy of course Serial1 is not shared with Serial like on some Arduino/etc boards that use a UART only to talk to the USB capable chip that connects to the host.
 
Last edited:
Thanks! That clears up a lot.

One more question, I'm still using up my 3.2s and I'm running into issues that putting text after native Serial.begin(xxx); is either ignored or jumbled up like pieces are being missed while it's trying to get everything out. Changing baud rates don't seem to help any. Adding delay() or what have you has not either. Any thought on this?

In this example I ran the processor at 48 Mhz. Typically I run them at 72 Mhz with the same issues.

For example :
C++:
// Like it says, prints help text.
void printHelp(void) {
   Serial.println();
   Serial.println("                             The list of commands available.");
   Serial.println("           ----------------------------------------------------------------------");
   Serial.println("list - Gives a list of the connected devices on the network.");
   Serial.println("fuel followed by a number 0..100 - sets the percentage of fuel to be broadcast.");
   Serial.println("seeName,showName or just name - This will display our device name.");
   Serial.println("seeValues, showValues or just values - Shows the broadcast information we can read");
   Serial.println("Hg - Shows the current broadcast barometer reading in inHg.");
   Serial.println("Mb - Shows the current broadcast barometer reading in mb.");
   Serial.println("findName folowed by a network address - If found, this returns the name of the item at that address.");
   Serial.println("copyName folowed by a network address - If found, copies the name of the item at that address.");
   Serial.println("pasteName or paste - Changes our name to the last one we copied.");
   Serial.println("changeAddr folowed by one value - Changes our address to that value.");
   Serial.println("changeAddr folowed by two values - tells the device at the first address to chnage to the second value.");
   Serial.println("bugs - Toggle whatever bug tracking messages currently in there on or off.");
   Serial.println("reset - This resets your name and address to what it was when the program started.");
   Serial.println("help, or ? - Well that's this. The command list.");
   Serial.println("           ----------------------------------------------------------------------");
   Serial.println();
}


void setup() {
   Serial.begin(9600);
   printHelp();
}

void loop() {
 

}

The result from the serial monitor is :

ver bug tracking messages currently in there on or off.
reset - This resets your name and address to what it was when the program started.
help, or ? - Well that's this. The command list.
----------------------------------------------------------------------
 
The fact it can decode some of the text suggests that both ends are at the same baud rate.
But the receiving end doesn't seem to be able to keep up with the transmission.
What is receiving the text?

Pete
 
I've not used the 3.2 (only the T4.x), so don't know if this applies in your case. In the T4.x, I've used the addMemoryForWrite() capability in the serial interface implementation to add extra memory that buffers characters written to the serial port.

Mark J Culross
KD5RXT
 
After you call Serial.begin(9600) in Setup(), you must wait until Serial is ready before you start writing to it, like this:

Code:
void setup() {
   Serial.begin(9600);
   while (!Serial) {} // wait for Serial
   printHelp();
}

Note that Serial will never be true unless you have the serial monitor open, so if you want your program to run even if you don't have the serial monitor open, then do this:

Code:
void setup() {
   Serial.begin(9600);
   while (!Serial && millis() < 5000) {} // wait for Serial, 5 sec max
   printHelp();
}
 
Code:
void setup() {
   Serial.begin(9600);
   while (!Serial) {} // wait for Serial
   printHelp();
}

Actually no, this fixes nothing. Exact same result.

-jim lee
 
The fact it can decode some of the text suggests that both ends are at the same baud rate.
But the receiving end doesn't seem to be able to keep up with the transmission.
What is receiving the text?

Pete
This is the built in, talking to Arduino IDE serial monitor. The development machine. (2023 Mac)
 
T_4.x can overwhelm the SerMon - the T_3.2 connects at 12 not 480 Mbs so generally not a problem.
@joepasquariello is right when that wait while(!Serial); completes the Host has established full readiness and Teensy should have a good connection - perhaps the computer is causing the issue.
Have not used a T_3.2 in some time - it was always reliable.
Serial.begin( baud ) wholly ignores the baud parameter for that USB, and when called will wait for about 2 seconds from power on with connection complete or not.
Perhaps put a delay(1); { or {2) } before and after the first printed line in the printHelp() and look for a change.
 
Screenshot 2025-03-27 at 9.04.50 PM.png
 
There you go. Compiled. run, asked to hold, failed.

Now, to be fair. I don't remember this being an issue back when the 3.2 was "the thing". Only in the last few years has this shown up and..

Wait, I just tested this on my laptop Mac. And it seems to work.

Desktop OS 14.4 MacBook OS 14.4.1 You guys may be on to something. Maybe it's the Mac.
 
I noticed (on T4.1) similar missing early print statements where I was waiting for serial to come up and printed some text that never showed up. In the end it turned out, that the Win PC (in my case, not Mac) enumerated USB so that Serial was available, but was still busy with other enumerations. In fact I had MTP-Serial selected for USB, but no MTP code in program. Also USB enumeration needed an insane 6 s to enumerate.

To test if similar things happen add a, say 10 s delay before print, and reduce until early prints are missing.
Not sure about Mac, but on PC there are two possible Serial lines to choose from and I have frequently issues with the 'suggested' Serial line.
 
Does Serial1 hold the program while it's transmitting? It doesn't seem like it does. If not, is there something I can watch to make sure it's all done before adding more? What I'm seeing looks kinda' like I'm interrupting it while it's busy sending a string. Not that this is easy to tell, but I'm looking for things to try.
 
Back
Top