Embedded Programming


The first thing we have to do to program electronic circuits, is to understand the way they work, and fundamentally, knowing in depth the microcontrolles: their properties, functions and possibilities. So is a good idea to get some information about the microncontroller we use in our Fab ciurcuits, the Atmel ATtiny 44A. And the best way is reading the controller datasheet. Even if is a large document (280 pages!) and that is a very advanced level for those who, as me, don't have extensive knowledge in electronics, it is important to use it. You must read and consult the sections of overview and general information, pin configuration, CPU core, memory, power managment, system control, I/O ports, universal serial interface, analog to digital convert, memmory programming, electrical and typical characteristics. It's really important to read the main features once, and then, consult and check it every time we will make a new project. This will avoid us problems arise when designing our circuits and especially when programming. We need to know how they work and that features that have.

This was my first contact with a data sheet of a microprocessor. My knowledge of electronics are basic, so I have to say that the experience was far from simple. So in many sections rather than answer questions, they were generated. But reading some sections, such as pin configurations or electrical characteristics, was really usefull to learn for exaple how to design the PCB and how to program it depending on the device, what kind of power supply I need, depending on the capabilities of the microprocessor, or how many input or output devices I can connect to the processor. I must say that there were sections that practically did not understand the operation. First we need to go a little deeper in the electronics and computer technology to better understand the operation of a microprocessor and to better understand of a document like this. While I consider useful and necessary to have on hand and use these data sheets as a reference tool.


Coming back tho the ATtyni 44A, these are small microcontrollers from the Atmel AVR family home. They are very popular due to the facility with which they can be programmed, as they have a fairly simple design. Our ATtiny have a 4kB programmable flash memory, and have 12 pins. And is really important to understand what does each pin of the processor and how do they work, depending on the device you want to make.






To program a microncontroller for an electronic circuit, we need this elements: an ISP programmer (we make it in the fifth week of the Fab Academy), an electronic circuit with our ATiny44A microprocessor, and a miniUSB and USB-FTDI cables to connect the boards with computer (PC-ISP-FTDI board).

Then we just have to write the code to program de microntroller. There are a lot of possibilities. Fab Lab recomend us to write in C or C++. We can also try to program in Phyton and why not, in the Arduino IDE if this is your first contact with the programming code.



The Arduino IDE (Integrated Development Environment), based on Processing language, permit us to write sketches in a simple way. In fact, the microcontroller receives C code... but I did not write my code in this language! Internally, Arduino IDE translates the code, and use avr-gcc compiler, for the microcontroller understand what you have programmed.




I started loading some Arduino IDE examples. Then I went modifying and testing by changing commands and values (example), to get familiar with the codes.



My second option was try to use C code, using the Atmel Studio (if you have Windows 8 OS this is almost the unique way to programm using C). We can download the software as a guess user. You have to install Microsoft Visual Studio; wizard installer does it automatically. The C code is really hard if you are a beginner programmer. I studied some of the examples of the software. And we will definitely need more than a week to learn and practice with this code. If you're a Windows user, you also can try WinAVR.



Another option was to learn Python, so I started a course in Code Academy. Although it is for beginners, you need some basic technical knowledge.

One thing to keep in mind when you are learning multiple programming languages, is that although the syntax of some languages are similar, each has its own. So you need to know in which languages you consider spaces, capitalization, etc.



A practical idea to practice programming without getting bored programming, can be, in case you have an Arduino board and a starter kit, to slowly go about doing projects. Thus as we move towards more complex projects, we learn more about the programming language. Motivate since not only you have to write code like exercise, but also see results!


Definitely a fundamental class. As a key is to select a not very complex language to start, and gradually go stepping forward. And above all practicing, a lot.