乐鑫技术交流
直播中

王鑫

7年用户 1247经验值
私信 关注
[问答]

MCPWM组ID到底是什么?如何正确配置多个PWM呢?

我无法理解 MCPWM“组 ID”到底是什么,或者至少无法正确配置多个 PWM。现在根据 soc_caps 标头,我正在使用的 ESP32 有
代码:
#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
到目前为止,一切都很好。这就是我从技术参考手册 p.403 中的图片中猜到的

我不明白的是这如何适用于 ESP-IDF v5.0+ 中的新 MCPWM 驱动程序
当分配这样的驱动程序时,必须通过这个级联配置调用来配置定时器,然后是运算符,然后是比较器等等...
我基本上的 BDC 速度控制示例中复制了初始化代码。
在配置期间,某些“组 ID”必须设置两次,一次在 mcpwm_timer_config_t 中,一次在 mcpwm_operator_config_t 结构中。
代码:
  mcpwm_timer_config_t timer_config{
    .group_id = SOME_ID
    // ...
  };
  
  mcpwm_operator_config_t const operator_config{
    .group_id = SOME_ID
    // ...
  };
我的项目需要 4 个 PWM,我假设我可以使用 ID 0 和 1 两次。
所以我有两个从 MCPWM 组 0 运行的
PWM。还有两个从 MCPWM 组 1运行的 PWM。
但这似乎不起作用。一旦我在同一个 ID 上分配了第二个驱动程序,第一个驱动程序就会停止工作......?
这是应该发生的吗?初始化四个 PWM 的正确方法是什么?
/edit
ok nvm,它按预期工作......
不能说为什么它以前没有。

更多回帖

发帖
×
20
完善资料,
赚取积分