Week #8

Embedded Programming

This week's assignment is to program the board we designed 2 weeks ago using low level programming. To do that we have to read the datasheet for the microcontroller we used which is ATtiny44.
When I milled and soldered my board two weeks ago, I wanted to make sure everything works fine and to do that I used the Arduino IDE to program it.


Group Assignments

In this part we compared between two AVR families, ATtiny44 from tinyAVR family and ATmega328P from megaAVR family. For ATtiny44 we used avr-dude and FabTinyISP programmer and for ATmega328P we used Arduino UNO board.

Feature Comparison

The table below compares bwteen the two MCUs. “tinyAVR microcontrollers (MCUs) are optimized for applications that require performance, power efficiency and ease of use in a small package”, where “megaAVR microcontrollers (MCUs) are the ideal choice for designs that need some extra muscle. For applications requiring large amounts of code.”


Programming ATtiny44 using AVR-dude

Write the program in C language using Notepad++ text editor. In the Makefile, define settings like programmer, target MCU, clock rate and lfuse. Using “make” command, build the hex file to be uploaded to target MCU. Connect the FabTinyISP prorammer to USB and ISP cable between programmer and target board. Using the command defined in Makefile “make program-avr-fuses”, program the lfuse to target MCU. Using the command defined in Makefile “make program-avr”, upload the hex file to target MCU.

Programming ATmega328P Using Arduino UNO Board

Write code using Arduino commands. The target MCU should have the right bootloader burnt to be used on Arduino Uno board. Connect the board to USB and uplad the hex file. To butn a bootloader to a fresh ATmega328P, you can check the built in example from Arduino.

AVR-dude Vs. Arduino

Programming in C enables users to have more control and optimized execution. The code written in C occupies less memory than the code written in Arduino. Also, code written in C executes faster. Keep in mind to program in C, the MCU should not have a bootloader burn to it, which saves the flash memory needed for the bootloader.

Individual Assignments

Fixing the problem

As I mentioned in the week6 "Electronics Design", about that not all LEDs work when the board is connected by ISP Pin Headers or via Voltage Regulator.


When I was soldering the 2 pins for voltage regulator, by mistake I cutted the GND trace as shown in the picture below


So I used the remaining piece of copper and soldered the wire to it, but I forgot the second end of the wire which is connected to the rest of the LEDs.


The solution I made aimed at not distorting the PCB as much as possible, which is that I used the remaining copper front part of the pieces, and soldered two points with the two resistors, so that they were connected to each other, thus connecting all the LEDs together.



Microcontroller #1 / ATtiny45

ATTINY45 is high performance, low power controller from ATMEL. It is an 8 bit controller based on Advanced RISC architecture. It is one of members of ATTINYXX series, popular because of its small size and features.

Pin Configuration:

ATTINY45 is an 8 pin iC as shown in the ATtiny45 pin diagram below. All I/O pins of the chip here have more than one function.




2D Model:

All measurements are in millimeters.


Microcontroller #2 / ATtiny44

ATtiny44 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATtiny44 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.


For my PCB "HEXI_01", the connection was as picture below:




2D Model:

All measurements are in millimeters.


Microcontroller #3 / ATmega328p

ATMEGA328P is high performance, low power controller from Microchip. ATMEGA328P is an 8-bit microcontroller based on AVR RISC architecture. It is the most popular of all AVR controllers as it is used in ARDUINO boards.

There is no major functional difference between ATmega 328 and ATmega 328p except for power. This microcontrollers are mostly used in Arduino's. The Atmega 328 function the same like Atmega 328p but the 328p has very low power consumption using the ATMEL's PicoPower Features. Hence P stands for PicoPower.

Pin Configuration:

ATMEGA328P is a 28 pin chip as shown in pin diagram below. Many pins of the chip here have more than one function.




2D Model:

All measurements are in millimeters.


Arduino Reference

Arduino programming language can be divided in three main parts: Structure, Functions and Variables.

I learned about the Arduino references, and how I can write the code without any syntax or compilation error.

The basic structure of the Arduino programming language is fairly simple and runs in at least two parts. These two required parts, or functions, enclose blocks of statements:


A function is a block of code that has a name and a block of statements that are executed when the function is called.


A variable is a way of naming and storing a numerical value for later use by the program. As their namesake suggests, variables are numbers that can be continually changed as opposed to constants whose value never changes. A variable needs to be declared and optionally assigned to the value needing to be stored.


An Operator is a symbol that tells the compiler to perform specific mathematical or logical functions.

C language is rich in built-in operators and provides the following types of operators:


The Arduino language has a few predefined values, which are called constants. They are used to make the programs easier to read. Constants are classified in groups.






You can download my files here:

Previous Week Next Week