I was building a simple Blinkblink application on an STM8S, the. The LED on-off interval was controlled by Delaythe delay function using the TIM4 Interruptinterrupt. A button event monitor is using another external Interruptinterrupt to prevent the interference from the Timer Interrupttimer interrupt.
But I also found out that even the button event is not interrupted by the Delaydelay function, but the Functionfunction associated with it still gets interrupted by the Delaydelay function, it. It will only execute after delay() returns no matter how early I press the button.
Is there a way to bypass this? Should I enable another TIMERtimer (like TIM2) to independently handle the button event? I need some insights.
The Buttonbutton is controlled by relatedthe code here:
INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ //if the Button is pressed if(mode == 2) { mode = 0; } else { mode ++; } } main.c
void main(void) { CLK_Config(); GPIO_Config(); TIM4_Config(); /* Infinite loop */ while (1) { Switch_Blink_Pattern(mode); } } Delay FunctionThe delay function is from STM's demo, using TIM4:
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) { /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ TimingDelay_Decrement(); /* Cleat Interrupt Pending bit */ TIM4_ClearITPendingBit(TIM4_IT_UPDATE); } void Delay(__IO uint32_t nTime) { TimingDelay = nTime; while (TimingDelay != 0); } void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } }