Microcontroller programming can seem a bit tricky because there are many confusing choices to make. I remember how I felt in the beginning. With all the available compilers, IDE’s, programmers and programming methods – no wonder you get confused!
So, let’s break it down.
I struggled a lot with this when I was learning the microcontroller basics. I followed different tutorials and ended up with lots of different software on my computer. I also had a board for programming the chip. And I had no idea what I actually needed to make it work.
So to make microcontroller programming as simple as possible for you – here is an overview of what you need to do.
The Basics Of Microcontroller Programming
A microcontroller does not know what to do by itself. It’s your job to tell it what you want it to do.
So, you need to write a program code on your computer. You need to compile the code with a compiler for the microcontroller you are using. And you need to upload the compiled version of your program to your microcontroller.
Arduino programming is a bit easier if you want to start really simple.
Write your program code
The first step is to write your program code. This is usually done is C. But some compilers support other languages as well. Find out what other people who are using the same microcontrollers are doing.
It doesn’t matter what software you use to write code. You can even use Notepad for this step. I like to use a really simple editor. But one that supports «syntax highlighting» makes the coding a bit easier. For Windows, I would recommend using Notepad++
Compile your code for your microcontroller
Before you can upload your program to your microcontroller, you need to compile it. This means converting the code from human-readable code to machine-readable code.
Use a compiler that supports your microcontroller and compile your code into machine-code for you chip. A popular compiler is for Atmel AVR chips is avr-gcc.
After compilation you will have one or more files containing machine code. Then you need to upload these files to you microcontroller.
Upload the compiled file(s) to you microcontroller
Usually it’s one program file and a file for EEPROM and/or flash that you need to upload.
You need a physical connection from your computer to your microcontroller. Either you can use a dedicated programmer (such as the AVRISP) or if you have a USB programmable chip, you can program it through USB (which I think is the best alternative).
And you need a program for uploading the file(s). For AVR chips, you can use AVRDUDE.
You can find many tutorials on how to program different microcontrollers. You can usually find what you are looking for by googling “programming insert-microcontroller-model-here”
With the main steps of microcontroller programming fresh in mind, it’s time to start building. If you are starting out, I would recommend starting with a microcontroller board. Arduino is the simplest, but there are many more available.