Page 1 of 1

mcpwm_capture_enable() vs mcpwm_capture_enable_channel() surprise

Posted: Sun Jun 05, 2022 1:32 pm
by liebman
While updating from esp-idf 4.3.x to 4.4.1 I noticed that mcpwm_capture_enable() was deprecated in favor of mcpwm_capture_enable_channel(). So in mcpwm_capture_config_t I set cap_prescale the same as I had previously passed to mcpwm_capture_enable() in num_of_pulse. This resulted in a different motor speed. Reading the code for these two functions I found that mcpwm_capture_enable() adds 1 to this value where mcpwm_capture_enable_channel() does not. Can this either be documented or fixed? (maybe documented would be the safer fix).

Update: I do see that the documentation describes num_of_pulse as
Input capture signal prescaling, ranges from 0 to 255, representing prescaling from 1 to 256.
and cap_prescale as
Prescale of capture signal, ranging from 1 to 256
so maybe it just needs to be clearer in the documentation.