Are you an electronics hobbyist? I will help you to write your first embedded C program. ‘Mikro C pro’ is one of the popular embedded C software for PIC microcontroller. It is more user-friendly and has a set of inbuilt functions and commands. After compiling a microcontroller program in C using ‘Mikro C pro’,you will be able to generate .HEX files from the program codes.
What is .HEX file? .HEX file is a machine code that corresponds to our C language codes. Only microcontroller and microprocessor can interpret the .HEX files. After building a .HEX file, you need to write the .HEX file to the memory of micro controller. This process is called burning of microcontroller.
This article will give you an idea about getting started with ‘Mikro C’ programming for microcontrollers and how to build .HEX files.
What is .HEX file? .HEX file is a machine code that corresponds to our C language codes. Only microcontroller and microprocessor can interpret the .HEX files. After building a .HEX file, you need to write the .HEX file to the memory of micro controller. This process is called burning of microcontroller.
This article will give you an idea about getting started with ‘Mikro C’ programming for microcontrollers and how to build .HEX files.
Steps to create a PIC microcontroller project in ‘Mikro C’ (Getting started programming for microcontrollers)
- Open ‘Mikro C pro’.
- Navigate to Project>>New Project.
- 'Welcome to the New Project Wizard' window will appear. Click the Next button.
- Choose your PIC from the drop down menu, different types of PIC microcontrollers are available. We are using PIC16F877A, then click Next.
- You will be asked to set up the device clock frequency. Look into the crystal oscillator in your PIC development board where the frequency is marked in MHz. (eg: 4.00=4MHz) Give the clock frequency and click Next.
- Now choose any folder (project location directory) to save the project by clicking the Browse button as shown below.
- Put a name to the project and click Save, then Next button.
- Now you can see ‘Add file to project’ window, right now there is no work for you just click Next button.
- Now you have successfully created the new project, click the Finish button.
[Example] embedded C program: LED Blinking
How to build .HEX file from C codes using ‘Mikro C’
- Provide your program codes to the editor panel of ‘Mikro C’.
- After coding either navigate to Project>>Build or click the Build button.
or
- The program for PIC microcontroller using 'Mikro C' is essentially written in C language. Finally the compiler produces a .HEX file which contains the machine language instruction understandable by a microcontroller.
- After clicking the build button, if the codes are error free you will be getting a message “Finished successfully” at the bottom.
- This means that a .HEX (machine code) file is generated from the embedded C program code.
- Open the folder (project directory) to view the .HEX file.
- Next step is to burn this .HEX files to the memory of microcontroller. If you are new to burning then dig onto: How to burn PIC microcontroller?
Related articles
Ads
Nice post. Keep it up. I really enjoy the way you explain the things. Thanks a lot
ReplyDeletei've read that Micro C software full version is not free. what is available in the net is limited featured one, so where can i avail such full version software? I will start studying C language and building projects, i'm afraid getting stuck in the middle of the construction.
ReplyDeleteYou may download it via torrent
Delete