Uart confusion & a typo on pjrc.com

Hi everyone, I don't usually get involved on the forums but I'm very impressed with the Teensy, Paul, and this whole community. I came close to posting a couple times already but, thanks to existing threads, I was able to get eclipse and my new 3.1 playing nice on linux and get over a couple other hurdles.

Most recently I thought there was a problem with the 4D Systems goldelox library, but I managed to figure it out.

The 4D library didn't like "Serial1" (maybe it's too many steps removed from Stream, which the lib uses directly...?)
At any rate, it would work if I called it "Uart" like this page suggests: https://www.pjrc.com/teensy/td_uart.html
Code:
HardwareSerial Uart = HardwareSerial();
Goldelox_Serial_4DLib Display(&Uart);

I wanted to use Serial2 and Serial3 though. I dug into the definition of HardwareSerial() and happened to spot HardwareSerial2 and HardwareSerial3 below it.
Thus, to use the uart on pins 9 & 10 of the Teensy 3.1 it's
Code:
HardwareSerial2 Uart = HardwareSerial2();
Goldelox_Serial_4DLib Display(&Uart);  //now "Uart" == "Serial2"

Maybe this is more obvious to others, but this is my first venture into 'Arduino' with multiple uarts.
So I was thinking that this page https://www.pjrc.com/teensy/td_uart.html should give a little more detail on the numbering.

Also, I spotted a typo on that page: "Serail2"

Many thanks for an amazing product. You haven't seen the last of me!! :)
 
Thank you, but...

Thanks to your research (which was absolutely nowhere documented by the stupid 4D Systems Support), I modified my code to use the right serial port. I use a 4D Systems uOLED-128-g2 with a teensy 3.1

Sadly, as soon as I call any Functions related to Goldelox like
Display.putstr("Text Tests")
or
Display.gfx_Cls() ;

my programm hangs. (Which points to a very bad coding practice in the Goldelox lib. I would expect some kind of return value, not just to drift of into nirvana...) But since the Arduino SDK crashed several times today, it seems to me that the Java Code is even worse.

My Code so far:
#include "Goldelox_Serial_4DLib.h"
#include "GoldeloxBigDemo.h"
#include "Goldelox_Const4D.h"

//Goldelox_Serial_4DLib Display(&DisplaySerial); // Obviously unusable
HardwareSerial Uart = HardwareSerial();
Goldelox_Serial_4DLib Display(&Uart);

void setup()
{
delay(1000) ;
Serial.begin(38600);
Serial.println("Resetting Display...");
//Reset the display
pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
digitalWrite(2, HIGH); // Reset the display
delay(100);
digitalWrite(2, LOW); // Clear Reset
delay(2000);
Serial.println("Display Reset Done.");
}

void loop()
{
Serial.print("Loop\n") ;
Uart.begin(9600);

Serial.print("LOOP: Clear Display\n") ;
Display.gfx_Cls() ; // PROGRAM HANGS HERE
Serial.print("LOOP: Text Test\n") ;
Display.putstr("Text Tests") ;
delay(2000);
}

Any help, why the stupid uOLED is so damn difficult to get running, would be greatly appreciated. (while it works without problems on an arduino mini pro...)
 
Last edited:
As I recall, Serial1, Serial2, Serial3, on the Teensy 3, are static class instances.
No need to make a new instance of a different name.

Serial1.begin(9600);

is all that's needed. Odd that you'd have to create a new instance, and that might conflict with the static instance's use of the hardware and interrupt.
 
Back
Top