Page 2 of 2

Re: Crash in timer interupt when data type "float" is used

Posted: Tue May 22, 2018 5:29 pm
by JoaoLopesF
Hans Dorn, Very good hacking, this save my day, I trying avoid to use FreeRTOS notify in my timer of 1ms to not overload the system.
Your code works very well

Thaks a lot

Re: Crash in timer interupt when data type "float" is used

Posted: Wed May 23, 2018 12:24 pm
by Deouss
ESP_igrr wrote:Floats use the FPU while doubles are calculated in software. For reasons, using the FPU inside an interrupt handler is currently not supported.
Oh that is quite disappointing...
So when and how we can use floats? How soon you can add that FPU functionality?
Does this pertain only to Arduino framework or FreeRTOS in general when using bare esp-idf?
This is like one of the major features of ESP32 - like a super huge thing about fast FPU
Should be priority number one to implement it. Please do that asap )

Re: Crash in timer interupt when data type "float" is used

Posted: Wed May 23, 2018 11:56 pm
by ESP_Angus
Deouss wrote: So when and how we can use floats? How soon you can add that FPU functionality?
Does this pertain only to Arduino framework or FreeRTOS in general when using bare esp-idf?
This is like one of the major features of ESP32 - like a super huge thing about fast FPU
Should be priority number one to implement it. Please do that asap )
You can already use floats (with the FPU) in both Arduino & ESP-IDF. You can't do floating point calculations in an interrupt handler.

The solution is to restructure your code so that floating point calculations happen outside the interrupt handler. This is a good idea anyhow, as even with an FPU floating point math (especially division) can take more cycles than you may want to otherwise spend in the interrupt handler.

If you have code which does floating point math in an interrupt handler and you can't find a good way to structure it so that the math happens outside the interrupt handler, feel free to post it and we can probably make some suggestions.

Re: Crash in timer interupt when data type "float" is used

Posted: Thu May 24, 2018 1:39 am
by Deouss
Yes now when I see how this is normally done it makes sense. Interrupts should be as short as possible when it comes to instruction cycles. I was first thinking to calculate values on interrupts but that could slow down whole measurement process.

Re: Crash in timer interupt when data type "float" is used

Posted: Mon May 28, 2018 9:20 pm
by JoaoLopesF
ESP_igrr wrote:Floats use the FPU while doubles are calculated in software. For reasons, using the FPU inside an interrupt handler is currently not supported.
The sin() and cos() functions of math.h, is for double (as ESP_igrr said -> its is calculated by software and not FPU)

Has anyone ever used fastmath.h?
These use float instead of double.
Can I replace sin and cos by sinf and cosf?