UART config not possible

Hey Guys

I am currently working on a project where i would like to read some data via the Serial Port (Pin 17 RX) on my Arduino Due.

The data has 8bit parity is even and 2 stop bits.

The data is coming from a RC-Contrler via an SBUS intface (every thing works and was measuret in the analoge domain).

If i try to configure the Serial2 via:

IN: [SBUS_exampleMy]

SBUS Sbus(Serial2); (constructor)

IN: [sbus.h]

class SBUS{
public:
SBUS(HardwareSerial& bus);

IN: [sbus.cpp]

SBUS::SBUS(HardwareSerial& bus)
{
_bus = &bus;
}

_bus->begin(_sbusBaud,SERIAL_8E2);

I just get:

Arduino: 1.8.12 (Windows 10), Board: "Arduino Due (Programming Port)"

F:\Documents\Arduino\libraries\Bolder_Flight_Systems_SBUS\src\SBUS.cpp: In member function 'void SBUS::begin()':

F:\Documents\Arduino\libraries\Bolder_Flight_Systems_SBUS\src\SBUS.cpp:60:35: error: no matching function for call to 'HardwareSerial::begin(const uint32_t&, UARTClass::UARTModes)'

_bus->begin(_sbusBaud,SERIAL_8M1);

^

F:\Documents\Arduino\libraries\Bolder_Flight_Systems_SBUS\src\SBUS.cpp:60:35: note: candidate is:

In file included from C:\Users____\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/Arduino.h:195:0,

from F:\Documents\Arduino\libraries\Bolder_Flight_Systems_SBUS\src\SBUS.h:27,

from F:\Documents\Arduino\libraries\Bolder_Flight_Systems_SBUS\src\SBUS.cpp:24:

C:\Users___\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/HardwareSerial.h:29:18: note: virtual void HardwareSerial::begin(long unsigned int)

virtual void begin(unsigned long);

^

C:\Users___\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\cores\arduino/HardwareSerial.h:29:18: note: candidate expects 1 argument, 2 provided

exit status 1
Error compiling for board Arduino Due (Programming Port).

By searching in the web i found some old posts where the conclusion was that config is not yet implemented is that true? And is there a workaround for it?

I realy need help i dont know what to do anymore....

Thank you very much for any feedback

HardwareSerial.h (1.31 KB)

SBUS.h (3.22 KB)

SBUS.cpp (11.9 KB)

SBUS_exampleMy.ino (2.43 KB)

Note that RX2 is for Serial2, and Serial2 is USART1.

Try this example sketch where I alter some USART parameters before sending/receiving. Likewise you can alter parameters for number of bits/parity/stop bits as necessary after reading the default parameters in US_MR register after initialization. Of course you'll have to adjust the baud rate.

These informations are page 828 of Sam3x datasheet.

/*********************************************************************/
/* Jumper between RX1 and TX2, and another one between TX1 and RX2   */
/*********************************************************************/

char c = 0;
void setup() {
 
  Serial.begin(250000);
  Serial1.begin(2500000); // USART0
  Serial2.begin(2500000); // USART1

  USART0->US_MR |= US_MR_MSBF | US_MR_INVDATA;
  USART1->US_MR |= US_MR_MSBF | US_MR_INVDATA;
  Serial2.print("Hello");
}


void loop() {
  String s;
  s.reserve(10);
  s = "";

  while (Serial1.available() > 0) {
    c = Serial1.read();
    s += c;

  }
  if (s.length() > 0) {
    Serial.println(s);
    Serial2.print(s);
  }
  delay(1000);
}

Thank you very much for your reply!

You are a true legend!
I got it to work.

Also the hint about the datasheet was very helpful.

Thank you and have a great day!

Hi both,

Do you alter the USART parameters prior to using the SBUS library as normal? Or how do these changes fit in with the original SBUS_exampleMy.ino sketch?

Thanks,

G

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.