IDF中怎么没有mcpwm_timer_set_period这个接口呢

puttingbl
Posts: 2
Joined: Thu Aug 22, 2024 7:37 am

IDF中怎么没有mcpwm_timer_set_period这个接口呢

Postby puttingbl » Thu Aug 22, 2024 7:41 am

在网页的编程指南看到有mcpwm_timer_set_period,但在ESP-IDF5.11跟esp-idf5.3都没找到这个函数,芯片是ESP32S3

puttingbl
Posts: 2
Joined: Thu Aug 22, 2024 7:37 am

Re: IDF中怎么没有mcpwm_timer_set_period这个接口呢

Postby puttingbl » Thu Aug 22, 2024 8:27 am

解决了,用IDF5.3版本,要先清除之前IDF5.11版本的编译

aliarifat794
Posts: 198
Joined: Sun Jun 23, 2024 6:18 pm

Re: IDF中怎么没有mcpwm_timer_set_period这个接口呢

Postby aliarifat794 » Thu Aug 22, 2024 3:26 pm

使用 `mcpwm_config_t` 结构体来配置定时器周期和频率。

Code: Select all

   mcpwm_config_t pwm_config;
    pwm_config.frequency = 1000;    // 1kHz
    pwm_config.cmpr_a = 0;          // 初始占空比 0%
    pwm_config.cmpr_b = 0;          // 初始占空比 0%
    pwm_config.counter_mode = MCPWM_UP_COUNTER;
    pwm_config.duty_mode = MCPWM_DUTY_MODE_0;
    
    mcpwm_init(mcpwm_num, MCPWM_TIMER_0, &pwm_config);

Who is online

Users browsing this forum: No registered users and 150 guests