« first day (4 days earlier)      last day (26 days later) » 

5:52 AM
At the same time, I am learning how to use MicroPython for ESP32, and perhaps try to run your program to generate PWM signals. I am starting to read the following referenes:
(1) ESP32 - Getting started with MicroPython on the ESP32

(2) ESP32 MicroPython Download (Also for RP2040, STM32 etc)

(3) espressif/esptool Public (pip install esptool)
I am using waiting for my new esp32 toys to arrive, hopefull sometime next week. In the mean time, I will try my luck on my old esp32 boards, which I bought some years ago, together with esp8266-12 boards. I only tried them to play with LUA, but found it very difficult to write the event driven LUA code. So I gave up. Below are the esp32 boards I found lying in my junk bin for 2 years, collecting dust:
1 hour later…
7:07 AM
But then SFexpress says my new toy esp32Ch9102x has already come to town. So I changed my mind and played with my new toy first.
So now I know BigTreeTech Official Shop ShenZhen takes less than 2 working days (Sat 0900 ~ Sun 2400) to delivery my tmc2225 toy.
7:37 AM
Now I am going to write a esp32 micropython program to do the following:
tmc2160Send16kStepsAt1Kz() # send 16,000 step pulses of PWM frequency 1 kHz, ie, each step pulse width is 0.001s or 1ms. So the 1.8 degree/step, 200 steps per revolution, motor should move 16000 steps, or 16000 / 200 = 80 revolutions. The time taken should be (16000 steps) / 1 ms/step = 16 seconds.
Note: The OP's program creates a PWM signal frequency, eg, 1kHz, while my program creates individual steps pulses with pulse width 1ms. In other words, the OP can specify to move the motor for a period of time, say 1 second (resulting 1,000 step pulses), while I need to specify 1000 steps, (resulting 1 second).
This is a complete listing of my Rpi Pico MicroPython Program of sending 16,000 step pulses to the tmc2225 (tested on tmc2160).
8:18 AM
I found that my new esp32 new toy is devkit tvi.
So I guess it should be compatible or newer than you devkit c. So it should be easy for us to compare and contrast our programming code.
8:49 AM
I googled further and learned more about esp32, such as devKit C, devKit v1, Wroom, esp32 Adruino IDE etc. I have not googled much about MicroPython, my feeling is that it is not that mature. So I might goto Arduino first.
(1) esp32 Wikipedia

(2) esp32 devKitC

(3) esp32 devKitC Boards

(4) Insight Into ESP32 Features & Using It With Arduino IDE - LastMinuteEngineers

(5) esp32 devKit V1
After skimming the above googled references, I have the first impression is that esp32 is much more powerful than Rpi Pico MicroPython, though not so powerful as stm32. But for my humble IoT applications, esp32 with Arduino IED C++ is just optimum. (The OP's choice of Espressif's IDF is too pro for me hobbyists).
Ah, almost locking down supper time. So call it a day. Would carry on tomorrow.
(6) Carry On - https://www.youtube.com/watch?v=K2gMdOHmC94

(7) Day is done - https://www.youtube.com/watch?v=5UrunpqtcIE
3 hours later…
11:49 AM
Ah, when I made the earlier comments, it was a gloomy Sunday afternoon, so I wrongly though thought that it was time to get to bed. Actually it was only 4pm. So after a short nap I didn't found sleep and could play for a couple of hours more. :)
So I carried on my studies and made the following summary pictures.
I surprisingly found out that esp32 is strong in handling PWM stuff, and that what esp32 says "MCPWM" is actually "Motor Control PWM" and should be handy to do motor PWM.
So I think I must google in this mcpwm to be able to understand and debug the OP's code on PWM. Now more references I googled:
(8) In-depth ESP32 PWM Tutorial | How to use PWM in ESP32? - Ravi Teja, 2021mar12


(10) esp32 and pico DIY PROJECTS - Electronics Hub
12:15 PM
I skimmed Ref 9 and found it surprisingly complicated, because of its very lower level API and macros. An example is that it have macros to configure the deadtime of switching two half H-bridges, and also inputting motor speed by Hall sensors, and syncing two PWM operators for fault.
But I found two reasons that I should be use esp32's mcpwm: (1) They are too lowlevel, so may be good one is developing DC/BLDC motor drivers using two barebone half H-bridges, or power MSOFET current switches.
(2) The whole mcpwm is designed for BLDC/DC motors, nothing is considered with stepper motor in mind. In short, esp32 is "useless" for stepper motors. (3) And if we are using stepper motor drivers such as tmc2130/2160/2208/2209/2225, all the esp32 mspcm tricks are actually handled in hardware/firmware, so should be more time/compute efficient.
Conclusion, I will forget esp32 mcpwm and go direct use tmc2225 as planned.
Though I am not using mcpwm, I still need to create some PWM signals, perhaps using a library of something. So I am skimming Ref 8 to steal or borrow some ideas.
1 hour later…
1:45 PM
So after my disappointment to mcpwm, I went reading Ref 8 from Electronics Hub. I had a pleasant surprise: I learnt that, beside mcpwm, there is another pwm for LED control, called ledC. The tutorial summarize the following interesting points and APIs.
***A couple of interesting points about LED PWM Controller in ESP32***.
16 independent PWM Channels, divided into group of two with 8 channels per group.
Programmable resolution between 1-bit and 16-bits.
Frequency of the PWM wave depends on the resolution of PWM.
Automatically increases / decreases duty cycle without processor intervention.
***A list of all the LEDC APIs exposed by the driver. These functions are written for Arduino IDE port of ESP32***.

ledcSetup(channel, frequency, resolution_bits)
ledcAttachPin(pin, channel)
ledcWrite(channel, dutycycle)
ledcWriteTone(channel, frequency)
ledcWriteNote(channel, note, octave)
My quick and dirty conclusion is that this ledC is very good to create step pulses for the tmc2225 step motor controller.
Talk is cheap. Tomorrow I will try to show how to use esp32 ledC wpm controller to control tmc2225 to drive a step motor.
Bed time. See you tomorrow.

« first day (4 days earlier)      last day (26 days later) »