I register interrupt as:
Code: Select all
mcpwm_isr_register(MCPWM_UNIT_0, isr_handler, NULL, ESP_INTR_FLAG_IRAM, NULL);
Code: Select all
void IRAM_ATTR isr_handler(void *ctrl)
{
uint32_t mcpwm_intr_status = MCPWM[MCPWM_UNIT_0]->int_st.val; //Read interrupt status
MCPWM[MCPWM_UNIT_0]->int_clr.val = mcpwm_intr_status;
uint32_t cp_state = xthal_get_cpenable();
if (cp_state)
{
// Save FPU registers
xthal_save_cp0(cp0_regs);
}
else
{
// enable FPU
xthal_set_cpenable(1);
}
angle += step; // ***** simple float operation
// set duty for all 6 switches as MCPWM[MCPWM_UNIT_0]->channel[MCPWM_TIMER_0].cmpr_value[MCPWM_OPR_A].cmpr_val = lookup(angle);
if (cp_state)
{
// Restore FPU registers
xthal_restore_cp0(cp0_regs);
}
else
{
// turn it back off
xthal_set_cpenable(0);
}
}
Regards, Boris