How to setup serial with even parity?!

Hi there,

the API docs say, that I can setup the serial port config (parity etc..) with an optional 2nd argument in Serial.begin(...) ... This work's perfectly for leonardo, micro, ...

But for Arduino Zero this option is missing?

Compiler says:

/home/myname/.arduino15/packages/arduino/hardware/samd/1.6.2/cores/arduino/HardwareSerial.h:70:18: note: candidate expects 1 argument, 2 provided

If I check the mentioned header file, the begin() method has indeed just one argument, for baudrate. That's it. NO 2nd argument for serial port configuration.

So how do I setup the parity for this device's serial?

br,
Alex

P.S. Using Arduinoi IDE 1.6.6 with SAMD Core 1.6.2

If I modify the mentioned header file:

class HardwareSerial : public Stream
{
public:
virtual void begin(unsigned long);
virtual void begin(unsigned long baudrate, uint8_t config); // <-------- added
virtual void end();

the compile finished without any issue. But I do not yet have an zero to test in real...

Any comments? Indeed a bug (missing line) in samd core?

br,
Alex

1 Like

Filed a pull-request:

Just tried the following line in the sketch's setup{}, in IDE 1.6.6, samd core 1.6.2:

Serial1.begin(115200, SERIAL_8E1);

This compiles OK.

In the Arduino Zero core, HardwareSerial is an abstract class and has no implementation. Instead it's the UART class that inherits the HardwareSerial's interface and implements the Serial functions.

The UART class in turn calls on the SERCOM class. It's the SERCOM class that manipulates the Zero's serial port registers.