How to optimize handling of multiple inputs efficiently on STM32F4 using GCC?
Good day everyone, I am using an STM32F4 series (F429ZI) microcontroller clocked at 180 MHz, and I'm compiling my code using GCC for ARM. I have a series of 40 if statements that each check an input for an embedded board. Running through these statements is very slow.
The code is structured like this for inputs 1 to 40. They are not if-else-if statements. I would use a switch, but as far as I know, a switch only handles one case at a time, and multiple inputs could be on simultaneously. Is there a more efficient way to handle all the inputs without so many "if" statements?
4 Replies
maybe a polling task which sets an event group according to the pin?
Thanks for this @te0 , but could you please elaborate on how I might implement a polling task that sets an event group according to the pin?
More like, how would this approach improve the performance compared to the current series of if statements?
Perhaps a code explaining it would be most appreciated 🙏 @te0