Page 1 of 1

mcpwm 定时器无tez或tep中断

Posted: Tue Jun 15, 2021 9:20 am
by suifan
ESP32-WROOM-32UE
comit: af8bc4c

/**
* @brief this is ISR handler function
*/
static void IRAM_ATTR isr_handler()
{
uint32_t mcpwm_intr_status;
mcpwm_intr_status = MCPWM[MCPWM_UNIT_0]->int_st.val; //Read interrupt status
tmp = mcpwm_intr_status;
MCPWM[MCPWM_UNIT_0]->int_clr.val = mcpwm_intr_status;
}

mcpwm_config_t pwm_config;
pwm_config.frequency = 5000; //frequency = 1000Hz, i.e. for every servo motor time period should be 1ms
pwm_config.cmpr_a = 50; //duty cycle of PWMxA = 0
pwm_config.cmpr_b = 50; //duty cycle of PWMxb = 0
pwm_config.counter_mode = MCPWM_UP_COUNTER;
pwm_config.duty_mode = MCPWM_DUTY_MODE_0;
mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_0, &pwm_config); //Configure PWM0A & PWM0B with above settings
MCPWM[MCPWM_UNIT_0]->int_ena.timer0_tez_int_ena = 1;
MCPWM[MCPWM_UNIT_0]->int_ena.timer0_tep_int_ena = 1;
mcpwm_isr_register(MCPWM_UNIT_0, isr_handler, NULL, ESP_INTR_FLAG_IRAM, NULL); //Set ISR Handler
printf("TMR0TEZ intr status %d \n", tmp);

mcpwm_intr_status值一直为零,没有产生tez或tep中断。

Re: mcpwm 定时器无tez或tep中断

Posted: Wed Jun 16, 2021 5:51 am
by suifan
有没有mcpwm定时器中断的列子,给发一个参考下。

Re: mcpwm 定时器无tez或tep中断

Posted: Wed Jun 16, 2021 6:26 am
by ESP_Eavo
您好。
可以参考下这边的示例:https://github.com/espressif/esp-idf/tr ... rals/mcpwm

Re: mcpwm 定时器无tez或tep中断

Posted: Wed Jun 16, 2021 7:10 am
by suifan
好的,感谢回复!