cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F 103 SysTick ve Uart Interrupts

leventeyigel52
Associate II
Posted on November 29, 2012 at 09:38

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...
3 REPLIES 3
Posted on November 29, 2012 at 09:54

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.

JW

leventeyigel52
Associate II
Posted on November 29, 2012 at 13:00

I know it is not good idea and in first i did it. But i have 25 seconds delay and in this process my usart received data and I must process it. But in my main function code is already and i can't process it. and also every 1 second period usart receive data. How can I process it?

Posted on November 29, 2012 at 13:47

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..