In this tutorial we'll first create a Makefile. Next we'll write a small C file.
Finally we will create a .hex file with the help of our Makefile and we'll burn
the .hex file into the microcontroller.
A Makefile is a special type of file. It has no extension. So when you create this file, you just have to name it
Makefile or makefile (depending upon the system) and have to make sure that it has no file extension.
Makefile contains shell commands. So every time you do not need to write several lines of commands on the terminal. All you have to do is to give a single command
make and voila! Makefile will do the rest for you.
I usually used to write separate Makefiles for different projects. Recently while I was studying some sample projects of Elliot Williams, I got the impression of using just one Makefile for all projects. Later I edited his Makefile to make it more simple. I also added additional comments for better understanding.
Here is the full codes of that Makefile. You can use it for any project. It will translate any C file into .hex file and will burn the .hex file into the microcontroller's memory.
nano Makefile. You may use the Makefile which I've added before.
makeand hit Enter. It will compile the C file and will create all necessary files to generate the .hex file.
make programand hit Enter. It will generate .hex file and will burn it into our microcontroller memory.
Now we'll connect any pin of PORT-D with any of the three ACTIVE-HIGH LEDs (Red or Green or Yellow) and connect any pin of PORT-C with the ACTIVE-LOW LED (Blue).
If you have done everything perfectly, you will see the result like the following image (the photo is underexposed so you can see the blue and red LEDs).