Saturday, March 16, 2013

Programming Microcontrollers Introduction


            PROGRAMMING OF MICROCONTROLLERS

Programming or burning a microcontroller means to transfer the program from the compiler to the memory of the microcontroller. A compiler is a software which provides an environment to write, test and debug a program for the microcontroller. The program for a microcontroller is generally written in C or assembly language. Finally the compiler generates a hex file which contains the machine language instruction understandable by a microcontroller. It is the content of this hex file which is transferred to the memory of the microcontroller. Once a program is transferred or written in the memory of the microcontroller, it then works in accordance with the program.

In order to know how to program a microcontroller, we need a device called a burner/programmer. A programmer is a hardware device with dedicated software which reads the content of the hex file stored on the PC or the laptop and transfers it to the microcontroller to be burned. It reads the data of the hex file by connecting itself to the PC via a serial or USB cable and transfers the data to the memory of the microcontroller to be programmed in accordance with the protocols as described by the manufacturer in the datasheet.

The programmer and the compiler differ for microcontrollers from different companies. In some cases the compiler has programmer software inbuilt in it. You simply need to connect the programmer hardware and the microcontroller can be programmed from the compiler itself.
Steps to program the microcontroller:
1. Purchase a microcontroller capable of programming the microcontroller you are using. Ensure that it is compatible with the operating system you are using.
2.  Install the software which comes with the programmer.
3.  Connect the programmer with the PC and start the software.
4. Read the hex file which you want to burn in the software of the programmer.
5. Press the program/burn option in the programmer software. In either case i.e. whether the programming is successful or failed the programmer software will show the message.
        microcontroller programmer or microcontroller burner
A microcontroller programmer or microcontroller burner is a hardware device accompanied with software which is used to transfer the machine language code to the microcontroller/EEPROM from the PC. The compiler converts the code written in languages like assembly, C, java etc to machine language code (which is understandable by the machines/microcontrollers) and stores it in a hex file. A microcontroller programmer acts as an interface between the PC and the target controller. The API/software of the programmer reads data from the hex file stored on the PC and feeds it into the controller’s memory. The target controller on which the program needs to be burned is placed on the programmer using a ZIP socket. The software transfers the data from the PC to the hardware using serial, parallel or USB port.
                                               
 
Depending on the way it interacts with PC, there are three types of microcontroller programmers:

1. Parallel Programmer uses the parallel port of the PC. They are low cost programmer but not widely used.
2. Serial Programmers uses the serial port to interact with PC via RS232 protocols. They are more popular among hobbyist working on PC. However both the serial and parallel programmers will become obsolete in near future. The major reason being unavailability of parallel and serial ports in the PCs & Laptops in the coming years.

3. USB Programmer uses the USB interface to transfer the data from PC. The main advantage of the USB burner is that they are powered from the PC itself and there is no need of any additional supply.  The USB programmers have already become popular and will soon replace the serial and parallel programmer.

The programmer generally contains a microcontroller which is preprogrammed to take data from the PC and program the target controller. The programmer burns the target controller using any of the protocols like SPI, parallel interfacing, I2C/TWI or CAN. The speed of burning depends on the way of programmer is interfaced with PC and the protocols used to burn the target controller.

The conventional method to burn a controller is to take it out the circuit, place it on burner and then dump the hex file into the controller using the API. In order to remove this problem of removing the controller from the circuit every time it needs to be programmed, the controllers have now been upgraded with In System Programmer (ISP) feature. This allows burning/programming a controller without removing the controller from the circuit it is used in.  The latest controllers are coming with the feature like bootloader memory which allows self burning capabilities, i.e. such microcontroller controller does not need any additional programmer hardware. They need only an API to transfer the program to the target controller. This API can also be incorporated in the compiler and hence the compiler can directly burn the target controllers.

                                                ENJOY  !!           

No comments:

Post a Comment