Understanding MCPWM "group IDs"

vinci1989
Posts: 27
Joined: Mon Oct 08, 2018 6:07 pm

Understanding MCPWM "group IDs"

Postby vinci1989 » Fri Nov 25, 2022 3:12 pm

I'm having troubles understanding what exactly a MCPWM "group ID" is or at least how to configure multiple PWMs properly. Now according to the soc_caps header the ESP32 I'm using has

Code: Select all

#define SOC_MCPWM_GROUPS                     (2)    ///< 2 MCPWM groups on the chip (i.e., the number of independent MCPWM peripherals)
#define SOC_MCPWM_TIMERS_PER_GROUP           (3)    ///< The number of timers that each group has
#define SOC_MCPWM_OPERATORS_PER_GROUP        (3)    ///< The number of operators that each group has
#define SOC_MCPWM_COMPARATORS_PER_OPERATOR   (2)    ///< The number of comparators that each operator has
#define SOC_MCPWM_GENERATORS_PER_OPERATOR    (2)    ///< The number of generators that each operator has
So far so good. That's what I would have guessed from looking at the picture in the technical reference manual p.403
MCPWM.png
MCPWM.png (41.73 KiB) Viewed 810 times
What I don't get is though how this applies to the the new MCPWM driver in ESP-IDF v5.0+
When allocating such a driver one has to go through this cascading config calls to configure a timer, then it's operator, then it's comparator and so on...
I've basically copied the init code from the BDC speed control example here.

During configuration some "group ID" has to be set twice, once in a mcpwm_timer_config_t and once in a mcpwm_operator_config_t struct.

Code: Select all

  mcpwm_timer_config_t timer_config{
    .group_id = SOME_ID
    // ...
  };
  
  mcpwm_operator_config_t const operator_config{
    .group_id = SOME_ID
    // ...
  };
My project would need 4x PWMs and I've assumed I can use ID 0 and 1 twice.
So I'd have two PWMs running from MCPWM group 0.
And two PWMs from MCPWM group 1.

However that doesn't seem to work. Once I allocate a second driver on the same ID the first one stops working...?
Is this supposed to happen? What would be the correct way to initialize four PWMs?

/edit
ok nvm, it works as intended...
Can't say why it didn't before.

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 124 guests