The object of choosing a programming language is to allow you to generate a hex file which is used to program the microcontroller.
There are three main choices for the language you choose based on what is
currently popular (and therefore what tools are available).
The obvious choice is assembler - but you can spend a great deal of time working out exactly how to get the job done.
The other three choices are Pascal, BASIC or C and it really comes down to your preference but even though C is more difficult I would recomend using C for the following reasons:
1. It is an industry standard.
2. You can do anything in C - BASIC as some point will limit what you do.
3. C is structured and therefore easier to maintain and use.
4. There are many C examples and code freely avaliable.
The following is a more in depth discussion
of the features of each language.
Assembler is the most obvious language that you'll consider using
as you probably won't need to buy any other tools to use it. More
than likely the manufacturer will provide an assembler for the
chip and you won't need any books as all the instructions are in
the datasheet and you just start coding.
This route to programming is very easy but you may be setting
yourself up for problems later on as:
There is no doubt that assembler gives the fastest and most optimized code
(your brain is better at optimization than any compiler!) but assembler is
difficult – typically you'll spend ten times as long writing assembler as you
would writing in a high level language.
This is the trade off; to write the fastest most optimized code or to get
the task solved more quickly.
Another problem with assembler is that to do even the most trivial task you have to think about every aspect of the code and all implications on registers and register flags.
Even making a microcontroller perform the most trivial task is difficult e.g. for making a loop in assembler you need to think about which register to use and which instructions all the while thinking about how those registers should not interact with the loop register/other registers etc.
Another difficulty is when you change from one microcontroller to another
(even in the same device family) the assembler instructions may be changed e.g.
more instructions to improve microcontroller performance. So you will have to
learn an entirely different instruction set when moving either to a new target
microcontroller or moving to a different device within the same family i.e.
code re-use is not possible unless you stay with one microcontroller (or
devices with a similar internal architecture).
Retargeting code to another microcontroller is easier since the HLL will
know the details of the new target i.e. instruction set, fuses etc. All you
need to worry about is the specific differences between the different
microcontrollers (in the same family this will be setting up the internal
The important point is that the HLL takes care of the assembler code needed to do the job.
The most useful aspect of a high level language (HLL) is that the language
is written in a form you can easily understand – there are no cryptic
assembler commands that you have to remember and most commands are made up of
several machine code instructions – saving you coding effort (often there are
built in libraries of code e.g. LCD driver, Serial port driver, I2C driver
So the HLL makes it easy to write code as it generates the correct assembler for the target microcontroller.
You can also make use of white space (areas of no code) to separate out the
various operations within the program – typically assembler code is just one
great big list that is really very difficult to read – I know there are
comments but you need to comment almost every line so that someone else can
understand the code.
One of the best features of a HLL is that you can split tasks into separate
functions that you can concentrate on them individually (as the HLL takes care
of local variables etc.). For assembler even when using a call instruction you
have to take care of preserving the register state – in the HLL it's all done
Once you learn the HLL you will
find it easy to read code written by other people and you will be able to
re-use code that you have already written whereas with assembler you will
constantly need to analyze the code to see if it fits in with your new
The only decision then is which high level language? There are really three contenders BASIC, C and Pascal – these are the most popular languages and for popular microcontrollers there will be an HLL compiler for each one. I'll just list the advantages and disadvantages of each
Note: Because the language is not standardized it will be difficult to move code to a new processor target type.
Claim Your: Useful
"Arduino Software Guide"
The Essential Guide to the DHT22/11 humidity sensor including a library code guide for the Arduino. Learn how to determine Humidity, Dew point and Heat Index.
The Essential Guide to the MAX7219; What it is and how you can easily use one in any of your projects.
How to Easily Use the DS18B20 Maxim One-Wire thermometer with Arduino example code showing external or parasitic power modes.