janelia-arduino/TMC2209

Hardware UART no longer working on ESP32 boards due to Espressif updating from 2.X to 3.0

benpeart opened this issue · 7 comments

I recently started investigating using your library for a ESP32 based project I'm starting but could never get any of the UART based examples to work. After spending way more hours than I'd like to admit, I finally figured out why.

In November of 2023, the Arduino Espressif ESP32 boards package updated from 2.X to 3.0, and apparently the hardware UART code has changed as none of the examples run properly anymore. When I revert to version 2.0.17 of the boards library, they all work correctly.

All 3.0.0 version migration related issues are discussed here if you would like to look at them.

The UART specific migration issues are documented here

Thank you for all the work you have put into this library! Let me know if/how I can help.

Hi! Which version of this library are you using? The last version update 9.1.1 should hopefully have fixed this issue. Were you using the latest version?

I'm using 9.1.1. Everything complies and 'runs' - it just never successfully communicates via UART. Using the Step/Dir/En pins works fine, just all serial communication/interfaces fail as if they aren't connected. I assumed forever that I just had the TX2/RX2 pins wired up wrong but after switching to the older board library they all work great. FWIW, this issue isn't unique to your library, the TMCStepper library I also looked at works with 2.x but not 3.0.

image

C:\src\TMC2209>git log
commit 60e32c02b829d14033bfc18786ff6206d2dd4954 (HEAD -> main, tag: 9.1.1, origin/main, origin/HEAD)
Author: Peter Polidoro <peter@polidoro.io>
Date:   Wed May 15 11:04:33 2024 -0400

    end(false) -> end() to work with esp32 3.x versions.

Here is how I have things wired up but given it is working with the 2.x version of the Espressif board package I'm pretty sure things are correct:
image

As an aside, I am working on a nearly identical set up and I am curious why you use two 22k resistors on the UART line rather than a single 1K resistor as shown on page 20 of the TMC2209 datasheet. Obviously, it works for you, but I am curious as to why this was chosen. Thanks

Sorry about the confusion there. I'm actually using a 1K resister on the TX line as specified on the datasheet. I was just being lazy and had never figured out how to choose the correct resister resistance in the Fritzing application (at some point I must have closed the Inspector window). I just googled it and fixed my laziness. :)

I had added a 10K pull down resister when trying to debug why UART communication wasn't working and observing via an oscilloscope that the line appears to be held high and I wasn't getting a big drop in voltage as the data was getting sent. I just removed the 10K pull down resister (now that I figured out that the issue was actually the 3.0 ESP32 board library) and it's still working correctly.

Here is an updated breadboard diagram with both issues fixed:

image

Thanks!

So do you have any idea of what I need to change in this library in order to get it to work with 3.0?

I'm sorry but I really don't. I'd start by looking at the UART specific migration issues to see if you are doing any of the things they have listed in the "functional changes" as those are more insidious than API changes which typically generate compiler errors.