Go Down

Topic: DUE serial port initialization (Read 1 time) previous topic - next topic

ltheoret

Hi,

I was using a Benchmark sketch I download from this site a long time ago. I got this sketch to work with every board I own from Chipkit to ZERO to 101 etc.., but it would not work with the DUE. So I started writing a DUE specific benchmark sketch. while doing this I found that if you do a pinMod(0, OUTPUT) or a pinMod(0, INPUT) for ports 0 or 1, this buggers up the serial port to the terminal. the Serial.begin(9600) does not re-initialize the port as expected.
Is there a way to re-initialize the serial port before trying to use it after doing the benchmark?

Luc

MorganS

Is there a good reason for doing this? Usually you don't change the purpose of a pin after the Due is switched on.

I'd start by looking at the code that's called before setup() to see if it's setting any registers which are related to serial communications, which get changed by the pinMode() function.
"The problem is in the code you didn't post."

ltheoret

Hi,

No good reason. Like I said this is for Hardware benchmarking.
The original code is found here:
https://forum.arduino.cc/index.php?topic=326944.0.

I modified it to work with almost every board. I just found if I use SerialUSB it works but that means having a specific sketch for a specific board when none of the other boards need it.

Is there a way to initialize SerailUSB.Begin() and still use Serail.print().

Luc

ard_newbie


I suspect that if you use Serial.end(); before using I/O pins Rx/Tx for another purpose than Serial.print();, you can come back to their original purpose and use again a Serial.begin().

You can independently use SerialUSB.begin(9600); and/or/or not Serial.begin(9600);

weird_dave

Is there a way to initialize SerailUSB.Begin() and still use Serail.print().
Code: [Select]
#define Serial SerialUSB

MorganS

Or use SERIAL_PORT_MONITOR which should be #defined on every different board
"The problem is in the code you didn't post."

ltheoret

Hi,

Thank you all for your help. I got it working somewhat.
It only works using SerialUSB and then using the Native port to read the data.

If anybody wants my code I can post it. I just added defines for all the different boards I have.
The ZERO, TIAN, Adafruit Feather M0 and all other SAMD board use the same definition. I also added a analog speed up routine for the SAMD. so the results you get is not out of the box for the SAMD set of boards.

Luc

Go Up