STM32F4: Timer Interrupt

  In this example we want to introduce ".c" and ".h" files and how to use them to make our projects more modular.

 We use from Example-2 as a template, and explian an modular coding in Keil uVision.

Copy & past "LastName-StudentID-002", and rename it to "LastName-StudentID-002-Modified". Open "GPIO.uvprojx" using Keil uVision5.

Modified-1) We want to use the pre-processing command #include to turn our code more modular. Open "main.c" and change it to this main.c (click here)

Modified-2) In the next step we want to build a "main.h" and a "main.c" to turn our code more modular. On the left, in the project window, under src folder, make right click and select "Add New Item to Group 'src'...". New window will open, Select "Header File (.h)" and name it "main" and and add it in .\inc folder.

First time Keil uVision

Type for example this main.h (click here) and Then change "main.c" to this main.c (click here)

Modified-3) Projects could be more modular if we build different necessary ".c" and ".h" files.

  Note1) It is better to write functions of one category inthe same ".c" file.

  Note2) We usually write the prototype of the functions, defines, extern of global variables, etc. in header files but this is not a strict rule.

  For example this project:

First time Keil uVision

THE END.

Sharif University of Technology, Tehran, Iran