Code: Select all
ESP_ERROR_CHECK(
mcpwm_new_capture_timer(
&(mcpwm_capture_timer_config_t)
{
.clk_src = MCPWM_CAPTURE_CLK_SRC_DEFAULT, // All input capture operations use the APB clock (80 MHz)
.group_id = 0,
},
&m_mcpwm_cap_timer
)
);
ESP_ERROR_CHECK(
mcpwm_new_capture_channel(
m_mcpwm_cap_timer,
&(mcpwm_capture_channel_config_t)
{
.gpio_num = GPIO_PIN_ICAP,
.intr_priority = 3,
.prescale = 1,
.flags.pos_edge = true,
.flags.neg_edge = false, // Capture rising edges only.
.flags.pull_up = false,
.flags.pull_down = true,
},
&m_capture_channel
)
);
TaskHandle_t current_task = xTaskGetCurrentTaskHandle();
mcpwm_capture_event_callbacks_t capture_callbacks =
{
.on_cap = CaptureInterruptHandler,
};
ESP_ERROR_CHECK(mcpwm_capture_channel_register_event_callbacks(m_capture_channel, &capture_callbacks, current_task) );
What I want to do is profile how much time the CPU is spending in the ISR, by reading a high res timer. This needs to be very efficient due to the high frequency of the interrupts.
I thought maybe I could read the raw (i.e. current) value of the capture timer at the start and end of the ISR, but there is no API function to do this.
I tried read it directly with
Code: Select all
DPORT_REG_READCode: Select all
uint32_t mcpwm_timer_value = DPORT_REG_READ(MCPWM_TIMER0_STATUS_REG(0));
I also tried MCPWM_TIMER0_STATUS_REG, MCPWM_TIMER1_STATUS_REG, MCPWM_TIMER2_STATUS_REG and values 0 and 1 for the MCPWM module index, but they always read as 0.
Should this work, or is it a dumb idea?