Welcome! Log In Create A New Profile

Advanced

Marlin: Pin assignment for ESP32

Posted by godageprasad 
Marlin: Pin assignment for ESP32
December 31, 2024 11:33AM
Hello All,
I am getting familiar with Marlin. Recently I have rotate motor with G-code with Arduino Mega 2560.
I am exploring option to use ESP32. In pins_ESP32.h file below pin assignment is present. But I couldn't understand pin like 128,129 etc. ESP32 doesn't have such pin numbers.
Please anybody can explain these pin assignment?
Thanks in advance.

// Steppers
//
#define X_STEP_PIN 128
#define X_DIR_PIN 129
#define X_ENABLE_PIN 130
//#define X_CS_PIN 0

#define Y_STEP_PIN 131
#define Y_DIR_PIN 132
#define Y_ENABLE_PIN 133
//#define Y_CS_PIN 13

#define Z_STEP_PIN 134
#define Z_DIR_PIN 135
#define Z_ENABLE_PIN 136
//#define Z_CS_PIN 5 // SS_PIN
Re: Marlin: Pin assignment for ESP32
December 31, 2024 05:37PM
esp32 does not have sufficient IO pins for most 3d printers, so an IO expander chip is used

There are two different types of io expanders currently implemented

One is via serial, pins >= 100 on this type of IO expander are on the expander.
The other is via i2s when pinis with bit 8 is set ie >= 128 are on the expander.

See Marlin/src/HAL/ESP32/fastio.h for more details.

Edited 3 time(s). Last edit at 12/31/2024 10:03PM by Dust.
Re: Marlin: Pin assignment for ESP32
January 01, 2025 02:56AM
Thanks for reply.
I am trying to rotate motor for 2 axis only (X,Y) at fist stage.
I have considered pins from pins_ESPA_common.h. (FYSETC E4 board ) I can complied code now. But I couldn't connect it "Pronterface" with serial 0.
I tried #define SERIAL_PORT_2 1, but it gives error 'MYSERIAL2' was not declared in this scope "
Is it any way we can configure port 2?
Re: Marlin: Pin assignment for ESP32
January 01, 2025 04:52AM
You need to make a few small code changes to have a second uart on esp32
In standard diff format.

Make these changes


diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp
index 145662215a..29804d34e9 100644
--- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp
+++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp
@@ -25,5 +25,6 @@
 #include "FlushableHardwareSerial.h"

 Serial1Class flushableSerial(false, 0);
+Serial1Class flushableSerial2(false, 0);

 #endif

diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h
index 012dda8626..8fbcca9f1a 100644
--- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h
+++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h
@@ -32,3 +32,5 @@ public:
 };

 extern Serial1Class flushableSerial;
+extern Serial1Class flushableSerial2;

diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h
index 0acb3676a2..a835dcf88d 100644
--- a/Marlin/src/HAL/ESP32/HAL.h
+++ b/Marlin/src/HAL/ESP32/HAL.h
@@ -51,6 +51,8 @@
 // ------------------------

 #define MYSERIAL1 flushableSerial
+#define MYSERIAL2 flushableSerial2

 #if ENABLED(ESP3D_WIFISUPPORT)
   typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1;

Edited 2 time(s). Last edit at 01/01/2025 05:07AM by Dust.
Sorry, only registered users may post in this forum.

Click here to login