C language is used to program the microcontroller, but the microcontroller itself understands hex instructions which are hard to code for us humans. Thus, the program is compiled to obtain the hex instruction to flash it in the microcontroller.The c compilation process converts the source code taken as input into the object/machine code. The compilation process can be divided into
four steps:Pre-processing, Compiling, Assembling, and Linking.
The Attiny44 used here is part of AVR , which is a family of microcontrollers developed since 1996 by Atmel. Thus,
AVR® Toolchain needs to be installed which is a collection of tools/libraries used to create applications for AVR microcontrollers.
Before writing the code, we were introduced t0 the
basics of I/O Pins for an AVR Microcontroller, and then the pinout of the attiny44 was studied to write the code using the correct pins from the
datasheet, which also defines the function of each pin, this will make us design the code and board according to our needs and with respect to availability of pins.
For writing the code, we used the software
CodeBlocks, which is a free open source C, C++ and Fortran IDE, and
Freematics Builder which is a fully self-contained utility which integrates all the toolchains, Arduino cores and libraries for easily uploading Arduino sketches or pre-compiled binaries to one of AVR based Arduino boards . Mac users weren't able to install it thus we had to borrow a windows laptop to work on it. It is worth mentioning that an Arduino is just an AVR microcontroller with some special boot loading code and a USB-to-serial converter. We had the opportunity to test the softwares on Arduino board by making it blink.
In Code Blocks, the processor chosen before writing the code is Atmega328p which is found in the Arduino.
Then, after verifying that the code is free of errors, the file is converted to .hex, which is used to inputd in the Freematics Builder to upload the code onto the board where the arduino starts to blink, verifying the validity of the code.
In the same manner, i wrote the code for the Attiny44 board and copied it to be used in the Arduino IDE.I connected the FabISP to board using the ribbon cable.Here i faced some issues making the laptop recognize my FabISP, thus i had to complete the process on my colleagues laptop. After detecting the FabISP, the following steps were followed in Arduino IDE:
- Tools>Board>Attiny24/44/84 (after installing Attiny44 library)
- Processor>Attiny44
- Clock>External 20MHz
- Programmer>USBtinyISP
- Tools>Burn Bootloader (this step is only done once)
- Sketch>Upload
Finally, the board was working as per the written code.
Downloads