Hi, I'm trying to convert a big Arduino code project to work on a Teensy 3.1 device. Being unfamiliar with the teensy device, I'm unsure why it doesn't allow serial output execution within the setup() function. The Arduino boards allow you to initialize the serial device and send serial output within the setup function, but not so with the Teensy device, not sure why, maybe because of the USB serial chip? The problem is the code I'm converting does a lot of hardware initialization within the setup function while outputting status to &Serial. This is broken and doesn't work on the Teensy 3.1 board. I tested the following code below and it works on Arduino, but not on Teensy 3.1 boards. If I move the serial print statements to the loop function, it works fine on the teensy hardware. Can someone please chime in and let me know why I cannot output serial data within the setup function below? Again, it works fine on Arduino boards.
I also attached the open source code I'm trying to convert that shows the hardware initialization within the setup function. I have resolved all compiler issues and it compiles error free, but I'm just trying to resolve why the code execution doesn't respond properly and why I can't output any serial information within the setup function.
Tnx,
Rob
#include <arduino.h>
#define MAIN_SERIAL_PORT &Serial
//HardwareSerial *main_serial_port;
usb_serial_class *main_serial_port;
void setup()
{
main_serial_port = MAIN_SERIAL_PORT;
main_serial_port->begin(115200); // USB is always 12 Mbit/sec
main_serial_port->println("Hello World..."); // no output to serial on Teensy, but works on Arduino using HardwareSerial class
}
void loop()
{
delay(1000);
}
I also attached the open source code I'm trying to convert that shows the hardware initialization within the setup function. I have resolved all compiler issues and it compiles error free, but I'm just trying to resolve why the code execution doesn't respond properly and why I can't output any serial information within the setup function.
Tnx,
Rob
#include <arduino.h>
#define MAIN_SERIAL_PORT &Serial
//HardwareSerial *main_serial_port;
usb_serial_class *main_serial_port;
void setup()
{
main_serial_port = MAIN_SERIAL_PORT;
main_serial_port->begin(115200); // USB is always 12 Mbit/sec
main_serial_port->println("Hello World..."); // no output to serial on Teensy, but works on Arduino using HardwareSerial class
}
void loop()
{
delay(1000);
}