Hello-
I am controlling a small stepper motor with the MCPWM module.
I need a function which will cause the PWM to emit a fixed number of pulses.
My first code uses the Capture module to count pulses, and then an if statement shuts down the PWM output when
the desired number of steps is reached. The capture module is firing an ISR at each pulse. This is creating a large number of interrupts!
I would like a way to configure the PWM to emit "n" number of pulses where n is an integer.
Hopefully this can be done such that the PWM does this autonomously without requiring many interrupts.
Your suggestions are appreciated!
Regards,
Greg
Set Number of Pulses from MCPWM?
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: Set Number of Pulses from MCPWM?
What you may be able to do is connect the pulse counter peripheral to the output pin of the MCPWM pin and generate an interrupt after n cycles that way. However, note that depending on your pulse frequency and what the ESP32 is doing, you may run the risk of getting to the ISR too late and accidentally sending out an extra pulse. Have you looked into using other ways to do this? I'd personally grab the RMT peripheral; depending on your exact requirements, this may solve your issue well.
Re: Set Number of Pulses from MCPWM?
Thank you, I am going to try both approaches. There is so much functionality on the ESP32, impressive!
Regards,
Greg
Regards,
Greg
Who is online
Users browsing this forum: No registered users and 83 guests