South Africa
Login / Register

Pic Programming fun

It’s Time for Fun

A microcontroller is a good-natured ‘genie in the bottle’ and no extra knowledge is required to use it. In order to create a device controlled by the microcontroller, it is necessary to provide the simplest PC, program for compiling and simple device to transfer code from PC to the chip itself. Even though this process is quite logical, there are often some queries, not because it is complicated, but for numerous variations. Let’s take a look.


Specialized programs in the Windows environment are used for writing a program for the microcontroller. This book describes one of them called mikroC PRO for PIC. The main advantage of this program is that it features many additional tools installed to aid in the development process.

If you have experience with program writing then you know that the point is to write all instructions in such an order they should be executed by the microcontroller and observe the rules of C language. In other words, the program you are writing just has to follow your idea! That’s all!

Program writing


The microcontroller does not understand higher programming languages as such, so that it is necessary to compile the program into machine language. A single click on the appropriate icon within the compiler results in creating a new document with .hex. It is actually the same program, only compiled into machine language which the microcontroller perfectly understands. Such a program is usually called a hex code and forms a seemingly meaningless sequence of hexadecimal numbers. When compiled, the program should be loaded into the chip. And you need appropriate hardware to make this happen. In other words, you need a programmer.

Hex Code

As mentioned, to enable a hex code to be loaded into the microcontroller it is necessary to provide a special device, called the programmer, with appropriate software. A large number of programs and electronic circuits used for this purpose can be found on the Internet. The procedure is basically the same for all of them and looks as follows:

  • Place the microcontroller in appropriate programmer’s socket;
  • Use an adequate cable to connect the programmer to a PC;
  • Open hex code document within the programmer’s software, set a few parameters and click the icon to transfer the code. After a few seconds, a sequence of zeros and ones is to be programmed into the microcontroller.

All that’s left is to install the programmed chip into the target device. If it is necessary to make some changes in the program, the previous procedure may be repeated an unlimited number of times.


This section briefly describes the way of using the mikroC PRO for PIC program (compiler) and PICflash programming software. Everything is very simple…

You have already installed mikroC PRO for PIC, haven’t you? Start it up, open a new project and a new document with extension .c within it.

mikroC PRO for PIC IDE

OK. The program has been written and tested with the simulator. It did not report any errors during the process of compiling into the hex code? It seems that everything is under control…

Yes, the program has been successfully compiled. All that’s left is to load it into the microcontroller.      Now you need a programmer consisting of software and hardware. Start up the PICFlash program.

The settings are simple and there is no need for additional explanations (the type of the microcontroller, frequency and clock oscillator etc.).

  • Connect the PC and programmer hardware via a USB cable;
  • Load the HEX code using command: File -> Load HEX; and
  • Click the Write button and wait…
PICflash programming software

That’s it! The microcontroller is programmed and everything is ready for its operation. If you are not satisfied, make some changes in the program and repeat the procedure. Until when? Until you feel satisfied…


A device, which in the testing program phase can simulate any device is called a development system. Apart from the programmer, the power supply unit and the microcontroller’s socket, the development system also features components for input pin activation and output pin monitoring. The simplest version has every pin connected to one push button and one LED. A high quality version has pins connected to LED displays, LCD displays, temperature sensors and all other components that a target device can be comprised of.

Mikroelektronika’s Development System

If needed, all these peripherals can be connected to the MCU via jumpers. This enables the whole program to be tested in practice even during its development stage, because the microcontroller doesn’t know or care whether its input is activated by  a push button or a sensor built in a true device.

If you have some of the development systems, the process of programming and testing a     program is even simpler. Concerning that the mikroC PRO for PIC compiler (on your PC)     and the PICflash programmer hardware (on your development system) cooperate     perfectly, the process of compiling a program and programming the microcontroller is     performed in a single step – by clicking the Build and Program icon within the compiler.     Now, any change in the program will immediately affect the operation of some of the     development system’s components.

Do you now agree with us that it’s time for fun?

Black and White Premium WordPress Theme