0
\$\begingroup\$

Trying to blink LEDs on STM32 dev board (F303 discovery) using SysTick interrupt. This is the snap of the simple code I wrote :

void SysTick_Handler(void) { GPIOE->ODR ^= 1<<14 | 1<<10;}

Nothing special. However, there are different color LEDs on the board, so I thought it would be great if I could take some input from user about color and blink that color LED, using interrupt.

But while defining the event handler I am not supposed to change the structure of definition (right?).So the handler can't take parameters.It would only handle a particular event. Is there a way I could do different events on same handler? Or do I have to use different timers?

\$\endgroup\$
3
  • \$\begingroup\$ It's a little unclear what you are trying to do, but likely you want user input to set some configuration information in a volatile flag somewhere, and then have the ISR look at that and to know which LED to blink. Probably always turn the unrequested ones off as the change in request may not be synchronous with the state of the LED. \$\endgroup\$ Jun 18, 2020 at 20:57
  • 3
    \$\begingroup\$ Ever heared of global variables (and volatile)..? \$\endgroup\$
    – Turbo J
    Jun 18, 2020 at 21:11
  • 1
    \$\begingroup\$ Use static (safer than global) variables as persistent flags if you can write it all in a self-contained function. \$\endgroup\$
    – DKNguyen
    Jun 18, 2020 at 23:20

1 Answer 1

0
\$\begingroup\$

Read the user input, store it in a variable, and in the systick, toggle the LEDs based on the variable.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.