Page 1 of 1

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

Posted: Thu Aug 22, 2024 7:41 am
by puttingbl
在网页的编程指南看到有mcpwm_timer_set_period,但在ESP-IDF5.11跟esp-idf5.3都没找到这个函数,芯片是ESP32S3

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

Posted: Thu Aug 22, 2024 8:27 am
by puttingbl
解决了,用IDF5.3版本,要先清除之前IDF5.11版本的编译

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

Posted: Thu Aug 22, 2024 3:26 pm
by aliarifat794
使用 `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);