Welcome! Log In Create A New Profile

Advanced

Modified SoftwareSerial to allow single pin UART for TMC2208

Posted by Pippy 
Modified SoftwareSerial to allow single pin UART for TMC2208
March 08, 2019 09:55AM
As the TMC2208 uses a single pin for UART comms MCU<>TMC2208, I thought it was a waste using separate Rx/Tx pins on the MCU that combined via a 1k resistor anyway.

So I've made a very small change to Arduino's SoftwareSerial module to allow the use of a single Rx/Tx pin .. this freed up the Tx pins on the mega's that were being used for my TMC2208's.

I'll do a 32-bit STM32F4 version of SoftwareSerial at some point soon too.

All you do is replace Arduino's two SoftwareSerial files with these, then you can set the Rx & Tx pins in your Marlin pins config file to be the same pin, the modified SoftwareSerial will do the rest.

NB .. The single Rx/Tx pin needs to have PCINT capability, which was the Rx pins I was using anyway.

You would have too move your 1k resistors that you have between your MCU Rx & Tx pins and place it from the new single Rx/TX pin (your old Rx pin) to +5V (simple pull-up) .. though the resistor may not be needed at all so could be removed depending on with TMC2008 driver board being used.

The two SoftwareSerial library files (SoftwareSerial.cpp & SoftwareSerial.h) on my system are here ..

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.h

They are the ones you replace with these modified ones - if you so wish.

So for me, I've gone from this ..

  #define X_SERIAL_TX_PIN    40
  #define X_SERIAL_RX_PIN    63

  #define X2_SERIAL_TX_PIN   -1
  #define X2_SERIAL_RX_PIN   -1

  #define Y_SERIAL_TX_PIN    59
  #define Y_SERIAL_RX_PIN    64

  #define Y2_SERIAL_TX_PIN   -1
  #define Y2_SERIAL_RX_PIN   -1

  #define Z_SERIAL_TX_PIN    44
  #define Z_SERIAL_RX_PIN    66

  #define Z2_SERIAL_TX_PIN   42
  #define Z2_SERIAL_RX_PIN   65

  #define E0_SERIAL_TX_PIN   -1
  #define E0_SERIAL_RX_PIN   -1

  #define E1_SERIAL_TX_PIN   -1
  #define E1_SERIAL_RX_PIN   -1

  #define E2_SERIAL_TX_PIN   -1
  #define E2_SERIAL_RX_PIN   -1

  #define E3_SERIAL_TX_PIN   -1
  #define E3_SERIAL_RX_PIN   -1

  #define E4_SERIAL_TX_PIN   -1
  #define E4_SERIAL_RX_PIN   -1

to this ..

  #define X_SERIAL_TX_PIN    63
  #define X_SERIAL_RX_PIN    63

  #define X2_SERIAL_TX_PIN   -1
  #define X2_SERIAL_RX_PIN   -1

  #define Y_SERIAL_TX_PIN    64
  #define Y_SERIAL_RX_PIN    64

  #define Y2_SERIAL_TX_PIN   -1
  #define Y2_SERIAL_RX_PIN   -1

  #define Z_SERIAL_TX_PIN    66
  #define Z_SERIAL_RX_PIN    66

  #define Z2_SERIAL_TX_PIN   65
  #define Z2_SERIAL_RX_PIN   65

  #define E0_SERIAL_TX_PIN   -1
  #define E0_SERIAL_RX_PIN   -1

  #define E1_SERIAL_TX_PIN   -1
  #define E1_SERIAL_RX_PIN   -1

  #define E2_SERIAL_TX_PIN   -1
  #define E2_SERIAL_RX_PIN   -1

  #define E3_SERIAL_TX_PIN   -1
  #define E3_SERIAL_RX_PIN   -1

  #define E4_SERIAL_TX_PIN   -1
  #define E4_SERIAL_RX_PIN   -1

So I've gained back 4 wasted pins (the old Tx pins) to use for whatever I wish.

I've done this using Marlin bugfix-2.0.x, I've not yet tried it with Marlin bugfix-1.1.x.

Edited 2 time(s). Last edit at 03/08/2019 10:13AM by Pippy.
Attachments:
open | download - SoftwareSerial.rar (6.6 KB)
Sorry, only registered users may post in this forum.

Click here to login