Interrupt low Latency - again

bmakovecki
Posts: 4
Joined: Fri Nov 03, 2017 9:20 pm

Interrupt low Latency - again

Postby bmakovecki » Thu Nov 15, 2018 7:27 pm

How can I minimize latency and execution time for interrupt ?

I register interrupt as:

Code: Select all

mcpwm_isr_register(MCPWM_UNIT_0, isr_handler, NULL, ESP_INTR_FLAG_IRAM, NULL);
in interrupt I have simple float operation as :

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);
}
}
Suggestions are welcomed, I hope I don't have to learn low level assembly language and CPU architecture for this.

Regards, Boris

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: Interrupt low Latency - again

Postby ESP_Sprite » Fri Nov 16, 2018 4:02 am

An obvious solution would be to not calculate as a float, so you don't have to mess around with floats. Instead, store it as a fixed-point number. I'm also not sure what your lookup() function does, but if it uses floating point numbers, you may also be able to get away with smallifying it by making it integer-only.

bmakovecki
Posts: 4
Joined: Fri Nov 03, 2017 9:20 pm

Re: Interrupt low Latency - again

Postby bmakovecki » Fri Nov 16, 2018 8:59 pm

Thanks for pointing me to fixed-point number. I think i can reduce interrupt execution time with your solution.
How about latency?
Can I make interrupt to trigger more precisely (cca 1us delay would be fantastic)?
Regards, Boris

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: Interrupt low Latency - again

Postby ESP_Sprite » Sun Nov 18, 2018 3:11 am

Unfortunately, that is harder as the Xtensa needs a fair bit of code to get from an interrupt vector back into an environment that is usable for C... what kind of latency are you getting now?

bmakovecki
Posts: 4
Joined: Fri Nov 03, 2017 9:20 pm

Re: Interrupt low Latency - again

Postby bmakovecki » Sun Nov 18, 2018 3:32 pm

This is what I see on osciloscope:
latency.png
latency.png (11.48 KiB) Viewed 5304 times

Who is online

Users browsing this forum: Corand and 88 guests