Sterling
DIIDevHeads IoT Integration Server
•Created by Sterling on 7/30/2024 in #firmware-and-baremetal
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?
5 replies