2012-11-29 12:38 AM
Hello everybody,
I have a problem. I'm using STM32f103rbt6. I'm using SysTick and USART interrupts. They are working independently. SysTick is used for Delay operation. But in a case, I must use this Delay function in USART interrupt service routine after I have received my all bytes. But in this case, Systick_Handler function doesn't work and don't change my timing variables. How can I overcome this problem and how can I use this function in each?Thank you very much...2012-11-29 12:54 AM
Unless you know exactly what are you doing, it is a BAD IDEA to use any delay in an ISR. (But if you know exactly what are you doing, you wouldn't be asking here...)
Instead, set a flag in the UART ISR indicating to the main loop that delay is needed, and then process it in the main loop. JW2012-11-29 04:00 AM
2012-11-29 04:47 AM
Sounds like you want to be buffering and queuing data so you can come back and process it later. ie you have a state machine that exits immediately if a delay is required, and is called later (1ms, 1s, whatever)
If you absolutely must have a small delay watch a free-running timer register (TIM or CYCCNT) tick, and wait for it to span a particular period. This probably won't help if you remain in the interrupt for a long time, as nothing else will happen in your system, so no real work will get done.