In this article we will discuss things we need to get started to microcontroller, especially programming and engineering a microcontroller.

All the things we need can be categorized into two:

  • Hardware
  • Software

The Hardware Part

Mostly we are facing hardware. In typical we will need following hardware:

  • Computer
  • In-System Programmer (ISP)
  • Target Board
  • Microcontroller

Computer

We need computer / laptop to write, edit, compile, and debugging the code before we send the program to the microcontroller. The requirements are not too much, at least it has spare resource to do our job. Any decent PC / laptop will do.

In-System Programmer (ISP)

We have our PC at one end with binary file ready to be written and a target board at another end. How can we transfer the program? For this we need a hardware called In-System Programmer or abbreviated as ISP (not Internet Service Provider). This devices programs the Microcontroller by burning the file (typically in hex format) into flash memory of microcontroller.

There are three type of ISP, according to the connector shape: Parallel programmer, Serial programmer, USB programmer. However, most ISP are now USB-based.

Parallel programmer – data is transferred through the parallel port of the PC. Technically the parallel port is called DB25 port as it has 25 pins. Any old school computer has this, usually referred as the “printer port”.

DB25

Serial programmer – The data is transferred throught the serial port of the PC. Technically the serial port is called DB9 port as it has 9 pins.

DB9

USB programmer – the data is transferred through the USB port of the PC. Typically, it use USB 2.0 standards.

SONY DSC

Target Board

Microcontroller cannot function on its own. If Microprocessor need motherboard to function, microcontroller need a board with an appropriate circuit to make it work. Sometimes we call it development board which have slot for the MCU to fit in, slots for other accessory drivers, ICs pins outlet of GPIO pins, etc.

There are many ready made development board out there. You can buy one of them or make them by yourself. It is always recommended for beginner to buy one or two different types of development board, but don’t go and buy random board. We need to consider the type of ISP and MCU and then choose the one according to our requirement and budget.

Microcontroller

Selecting the microcontroller is the biggest dilemma. There are more than 150 IC manufactures which manufacture MCUs, and each one of them can have more than dozens of different models in their account. So which one to choose?

By the popularity, there are two most popular microcontrollers: PIC by Microchip and AVR by Atmel.

When we are choosing microcontroller, we should consider many factors. But at least, we can consider following factors to decide what MCU we need:

  • Cost – A cheap MCU is always preferred. But many chips might offers competitive price with competitive features. Also remember that sometimes price and capability always been a tradeoff.
  • Speed – Speed of execution also matters. Running faster means accomplish work faster.
  • Ease of use – How ease of use means how many effort we need to learn the chip, assemble the system, maintain it or even upgrade the system if necessary.
  • Architecture – In simple words: RISC or CISC? There are two different categories of architecture, the Reduced Instruction Set Computing (RISC) and Complex Instruction Set Computing (CISC). In RISC, the instructions are highly optimized set of instructions rather than a more specialized set of instruction. While the CISC is the counterpart. In RISC less amount of instructions will result in more output, whereas in CISC more amount of instructions will result in less output. To do a particular job, RISC require lesser number of instruction than CISC. AVR and PIC are examples of RISC, while Intel 8051 and Motorola 68000 are based on CISC.
  • Compiler – Availability of compiler means ease our access to learn and code the microcontroller. Some manufacturer such as Atmel gives free compiler for their AVR, while other might charge it for some cost. Practically, they are more specific domain or specific purpose.
  • Durability – How long the microcontroller will last? How is the maximum or minimum constraint which tolerated by the microcontroller? This should be proven.

Choose any MCU you want.

The Software Part

In softwares, we have several subcategories:

  • Compiler
  • Debugger
  • Programmer

Compiler

We want to program the microcontroller. Like microprocessor, microcontroller only know machine code in some manners. They don’t understand human language. To bridge the gap, a programming language is created and a compiler is used to translate the programming language to the code known by the microcontroller. There are many different language and compilers available for different OS.

For programming language, C is preferred over other (such as BASIC), as it is more organized and gives us the power to do substantially more. Apart from this, C is a language which widely used in low level programming. It is powerful, like a sharp sword you should know what kind of weapon you are using.

Different microcontroller use different machine code and hence can have different compiler. You can use compiler for AVR to write a program for PIC microcontroller. You can however if there is a compiler which can translate our code to different target microcontroller.

Debugger

Debugger is a tool used to test and debug other program. Typically, the debugger will execute the instruction one by one and stop to whichever instruction interest us. The target program is the program written specifically for microcontroller.

Debugging process can be done in two different location: local and remote.

Debugging in local means the target program is run on our computer. We don’t upload the program to the microcontroller to know the execution, instead we let the debugger to run it in our system.

Remote debugging means the target program is run on the microcontroller. We connect our computer to debugging line of microcontroller and control the execution flow from our debugger. We then can set some register values, change the behavior, and stop at specific instructions.

Programmer

A programmer software is a bit confusing term. It is a special software used to utilize hardware programmer or ISP so we can transfer the program from our computer to the board. Most of the compilers have an inbuilt programmer. But sometimes people prefer to use a separate one because of greater flexibility it offers.

Some popular programmers are: PonyProg, avrdude, ProgISP.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">