From the course: C Programming for Embedded Applications

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

LUT vs. function example in Arduino

LUT vs. function example in Arduino - C Tutorial

From the course: C Programming for Embedded Applications

LUT vs. function example in Arduino

- [Instructor] In this practical example, we'll see the speed up obtained by using a lookup table instead of a regular function in a program that performs a big number of calculations. Again, this code is available in the exercise files folder, and I encourage you to play around with it. This is the longest source file in the course. You may want to take some time to look at the whole file, but there are only three parts I want you to pay attention to. First, we have three macro definitions in lines nine, 12, and 15, respectively, which modify the behavior of the code with ifdef directives. So you may leave either of these definitions or comment them out depending on how you want the program to behave. The first one is called USE_LUT, and it's there to select whether you want to use a lookup table or a regular function in the calculations ahead. We'll start disabling this macro to test the performance of a function…

Contents