Welcome! Log In Create A New Profile

Advanced

Marlin 2.0 - Enable Serial3 port

Posted by torri 
Marlin 2.0 - Enable Serial3 port
May 07, 2020 05:07PM
Greetings!

I want to enable Serial3 port in Marlin 2.0 firmware with different baudrate than Serial0.

I see that Marlin disables standard HWserial and configures the communication with its own methods.
I'm not sure what I have to modify. I have declared a new object as MarlinSerial Mserial3 and I have tried to configure Serial3 port baudrate but it modifies Serial0 baudrate too.

Does it exist the chance of configure Serial3 with standard HWserial separately? Through that port the communication won't be so continuous so I don't really need specified rx/tx buffer setups and other stuff. With the standard is enough.

Thanks in advance for your help.

EDIT: Code attached & Github:
[github.com]

Edited 1 time(s). Last edit at 05/08/2020 03:53AM by torri.
Attachments:
open | download - Configuration.h (70.3 KB)
open | download - MarlinSerial.cpp (24.9 KB)
open | download - MarlinSerial.h (6.9 KB)
Re: Marlin 2.0 - Enable Serial3 port
May 07, 2020 06:51PM
Without posting your code, or url to github... its very hard to make constructive suggestions.

There is no SERIAL_PORT_3 support in marlin, its not just enabling it...

Edited 1 time(s). Last edit at 05/07/2020 06:56PM by Dust.
Re: Marlin 2.0 - Enable Serial3 port
May 11, 2020 06:23AM
The code is Marlin firmware. Older versions than 2.0 would be acceptable because the problem is that UART communications are strictly limited to one port (I think).

My intention is, with an Mega2560 custom board, maintain USB communication and open another port (Serial3) to communicate with an external module.

Maybe somebody had this problem before to use Serial1 or Serial2 and knows how to do it.
Also I was thinking to create an additional source code file and trying to use Arduino standard Hardware Serial for Serial 3 but I'm not pretty sure if this disable the Marlin Hardware Serial.
Re: Marlin 2.0 - Enable Serial3 port
May 11, 2020 10:09AM
marlin 2 support 2 serial ports, can be uart or real serial over usb (on modern 32 bit controllers)
and it has support for a 3rd serial for some smart screens...
Yes it still run on RAMPS

No further development is going into marlin older than version 2..
Re: Marlin 2.0 - Enable Serial3 port
May 19, 2020 07:33PM
The issue is, within MarlinSerial.h, you define the serial port number (usually for usb) and the registers related to that port number are defined to be modified inside the methods from MarlinSerial.cpp.
This means that if you define SERIAL_PORT 0 and declare a MarlinSerial class object for Serial0 would be OK, but if you also declare another MarlinSerial object for Serial3 (for example), it won't works because MarlinSerial class methods are using Serial port 0 registers.

In Marlin 2 (I have some older versions and doesn't happen) there are an exception for Serial1 and within MarlinSerial methods there are operations with Serial port 1 registers if selectecSerialPort == 1.
That would be good and only changing Serial 1 for Serial 3 would be enough but there are two problems:

  1. MarlinSerial class defines only one baudrate. If you declares two MarlinSerial objects, the baudrate will be for Serial0 and Serial3 the last declared.
  2. rx_buffer object (from ring_buffer struct) is used by both ports.

So I have resolved this creating a new class using MarlinSerial methods but only for Serial3. Also I have declared a rx3_buffer.
Communications are working using 115200 baud for Serial0 and 9600 baud for Serial3. I have a problem with Serial3 reception which freezes the system. I hope during these days I can fix it.

Edited 1 time(s). Last edit at 05/19/2020 07:34PM by torri.
Re: Marlin 2.0 - Enable Serial3 port
May 07, 2021 01:55AM
SERIAL_PORT_3 has just been added to Marlin 2 bugfix (moments ago)
It is supported by most platforms, but not all.
Sorry, only registered users may post in this forum.

Click here to login