Interrupt callback function blocked by delay
Hey there !
I'm trying to use an ultrasound range captor on STM32 Nucleo. To beggin, I'm on a very simple case of use : User press a button, it's trigerring an interrupt, handled by a callback function `emettre_ultrason()`. Then, when the callback function have finished its work, the MCU should continue its stuff, until a reflected wave trigger a new interrupt.
`emettre_ultrason()`have to set a pin on `set` state for few x ms, then, to `reset` state. So the ultrasound emitter emit a wave during x ms.
The issue is : if I use `HAL_Delay()` to wait these x ms, the function is blocked because of this delay : I never go through the instructions next to the delay, I never go back to the main loop, as I can see with UART Trace.
I understood, by reading other topics as this one or this other one, that it's because delay are not supposed to be used in an interrupt handler. And even if it seems to be a bad practice, I tried yo put a higher priority on systick interrupts (with `HAL_NVIC_SetPriority` ) Without any result. But, I HAVE to emit this wave in my interrupt callback. Sooo I'm looking for what could be the better option.
I tried to improvise a solution like this :
```c
void custom_delay(int delay_requesti){
int core_frequency = 84e6;
int loop_laps = delay_requesti*core_frequency;
int i;
for(i = 0; i < tours; i++){
__NOP();
}
}
```
but hell yeah ! I'm pretty sure it's worth than use a delay ! :o It will be okay while debugging, but it's not acceptable for a study project. Do you have any suggestion to impose a short delay, juste while emitting a short impulsion ?
Thanks
