Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
#5 Preprocessor and the "volatile" keyword in C
Play lesson

Modern Embedded Systems Programming Course - #5 Preprocessor and the "volatile" keyword in C

4.0 (6)
56 learners

What you'll learn

This course includes

  • 22.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

Embedded Systems Programming Lesson-5 shows how to make the code more readable by using the C preprocessor. You also learn about the volatile keyword and how to use it to write programs that run correctly at any level of optimization. The lesson starts with showing you how to define macros and explains how the C pre-processor substitutes the macros before the actual compilation. Next, you define macros for all registers used in the "blinky" program and you test the code. Next, you learn about the vendor-provided header file that conveniently defines all the registers for you. You notice that the header file defines the registers as "volatile" and you learn what that means. You also learn that "volatile" can be useful not just for the registers, but also for the "normal" variables like the delay-loop counter. You increase the level of optimization to "high" and see for yourself that the compiler optimizes the delay loops "away". You fix the problem by making the loop counter "volatile". Finally, in the last step of the lesson, you learn how to actually include the "lm4f120h5qr.h" header file into your code and how to recognize the interesting registers in the header file. In the next lesson, you will learn how to use the bitwise OR and AND operators to blink the other colors of the composite LED and you will also learn about more advanced features of the GPIO registers. Stay tuned... --- Resources: Article: "Place volatile accurately" by Dan Saks: https://www.embedded.com/electronics-blogs/programming-pointers/4025609/Place-volatile-accurately Article: "Volatile as a promise" by Dan Saks: https://www.embedded.com/electronics-blogs/programming-pointers/4025624/Volatile-as-a-promise YouTube playlist of the course: https://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM Course web-page: https://www.state-machine.com/quickstart

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere