1. Compare the performance and development workflows for other architectures
   1. Read a microcontroller data sheet
   2. Program your board to do something, with as many different programming languages and programming environments as possible

Plan for  the week



In previous weeks, we did electronics production where we knew how to make the boards by milling, stuffing elctronics component with solder followed by designing the circuit by using CAD like eagle and tested it. Microcontroller is like an empty glass unless something is pushed inside it. In order to operate microcontroller as per our expectatiom, we have to push some logic inside the microcontroller based on which it operates. So that logic is attained by doing programming in differnt platformslike arduino IDE, Embedded C, Atmel studio etc. These platforms let us input in understandable language and finally to hex code that machine understand



A microcontroller is an integrated circuit (IC) which is small, low cost and self contained computer designed to handle a specific task in embedded systems. In simple words, a microcontroller (MCU or Microcontroller Unit) is a small computer integrated in to a single chip. We can also explain it as programmable silicon chip which is clock driven, register based, accepts input and provides output after processing it as per the instructions stored in the memory.
A computer is a general purpose device which we can use for word processing, watching movies, editing videos, web browsing, developing softwares etc. While a microcontroller is intended to do some specific tasks like controlling a washing machine, controlling an air conditioning etc.


Microcontroller consists of Arithmetical and Logical Unit (ALU), Control Unit and Register Array. As the name indicates ALU performs all arithmetic and logical operations on the data received from input devices or memory. Register array consists of a series of registers like accumulator (A), B, C, D etc. which acts as temporary fast access memory locations for processing data. As the name indicates, control unit controls the flow of instructions and data throughout the system. So basically a microprocessor takes input from input devices, process it as per instructions given in the memory and produces output.

Advantages or microcontroller

  1. Low Cost
  2. High Speed
  3. Small Size
  4. Versatile
  5. Low Power Consumption
  6. Less Heat Generation
  7. Reliable
  8. Portable    

Common terms used in MCU

  1. Bus: A bus is a set of conductors intended to transmit data, address or control information to different elements in a microprocessor. Usually a microprocessor will have 3 types of buses : Data Bus, Control Bus and Address Bus. An 8-bit processor will be using 8-bit wide bus.
  2. Instruction Set: Instruction set is the group of commands that a microprocessor can understand. So instruction set is an interface between hardware and software (program). An instruction commands the processor to switch relevant transistors for doing some processing in data. For eg. ADD A, B; is used to add two numbers stored in the register A and B.
  3. Word Length: Word Length is the number of bits in the internal data bus of a processor or it is the number of bits a processor can process at a time. For eg. An 8-bit processor will have an 8-bit data bus, 8-bit registers and will do 8-bit processing at a time. For doing higher bits (32-bit, 16-bit) operations, it will split that into a series of 8-bit operations.
  4. Cache Memory: Cache memory is a random access memory that is integrated into the processor. So the processor can access data in the cache memory more quickly than from a regular RAM. It is also known as CPU Memory. Cache memory is used to store data or instructions that are frequently referenced by the software or program during the operation. So it will increase the overall speed of the operation.
  5. Clock Speed: Microprocessors uses a clock signal to control the rate at which instructions are executed, synchronize other internal components and to control the data transfer between them. So clock speed refers to the speed at which a microprocessor executes instructions. It is usually measured in Hertz and are expressed in megahertz (MHz), gigahertz (GHz) etc.

Attiny24/44/84 datasheet


In order to use a microcontroller, a flip-flop, a photodetector, or practically any electronic device, you need to consult a datasheet. This is the document that the manufacturer provides telling you

  • the typical device performance
  • minimum and maximum requirements and characteristics
  • what you can do to the device without harming it
  • suggested uses and hints

You don’t have to understand everything in a datasheet. There’s a lot of information that might not be of any use to you. There are some important parts of the datasheet that you should pay particular attention. You can find datasheet of every electronic component in a pdf format. The datasheet of ATTiny 24/44/84 can be downloaded from this link.

Features of Attiny24/44/84

  1. High Performance, Low Power AVR® 8-Bit Microcontroller
  2. RISC Architecture
  3. Program Memory Type: Flash
  4. Program Memory (KB): 4
  5. CPU Speed (MIPS): 20
  6. RAM Bytes: 256
  7. Data EEPROM (bytes): 256
  8. Digital Communication Peripherals: 1-SPI, 1-I2C
  9. Capture/Compare/PWM: 1 Input Capture, 1 CCP, 4PWM
  10. Operating Voltage: 1.8 – 5.5V
  11. Speed Grade:
  12. 0 – 10 MHz @ 2.7 – 5.5V
  13. 0 – 20 MHz @ 4.5 – 5.5V
  14. Temperature Range: -40°C to +85°C
  15. Internal Calibrated Oscillator of 8MHz

Pin descriptions


For arduino

  1. VCC: Supply voltage. 
  2. GND:  Ground 
  3. Port B (PB3:PB0):  Port B is a 4-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability except PB3 which has the RESET capability. To use pin PB3 as an I/O pin, instead of RESET pin, program (‘0’) RSTDISBL fuse. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. 
  4. RESET:  Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running and provided the reset pin has not been disabled. The minimum pulse length is given page 177 of the datasheet. Shorter pulses are not guaranteed to generate a reset. The reset pin can also be used as a (weak) I/O pin. 
  5. Port A (PA7:PA0):  Port A is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port A pins that are externally pulled low will source current if the pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Block diagram

ATtiny24/44/84 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 ATtiny24/44/84 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.

block diagram

The AVR core combines a rich instruction set with 32 general purpose working registers. All 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers.

Physical Dimension



To every pin we internal pull up resistor connected to it. And there are 3 registors connected.

  • Directional registor: assigned by code "DDRA/DDRB" are the registors for Directing the registor normally used for assigning certain value to the registor.
  • Input registor: assigned by "PINA/PINB" are the input registor to take input from switches or sensors.
  • Outut registor: assigned by "PORTA/PORTB" are the output registor to supply signal to the output or actuators

Schematics from Electronics Design week


We will be using these for applying the embedded programmin gon the microcontroller. We will be taking PB2 for input and PA2, PA3 and PA7 as an output.

Embedded programing 

Arduino IDE

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. Download the Arduino IDE software from this link. Now that the software is downloaded install and open the software and follow the steps below


1. Open preferences
        file >> preferences


2. Copy the following link in the Additional boards manager
3. After adding the URL open Board Manager by clicking
        Tools >> Board >> Board Manager
    Search for ATTiny and install the board.


4. Select
    Board : ATTiny microcontrollers >> ATTiny 24/44/84
    Processor : ATTiny 84
    Clock: External 20MHz


5. Now click on bootloader. What bootloader does is it sets up the conditions for your board like frequency which is the reference for time. Whether the clock is external or internal etc
        Tools >> Bootloader


Now that you have setup the settings write a program according to the pin numbers shown above. You can get to know about arduino coding from this link.

// constants won't change. They're used here to set pin numbers:
const int ledPin1 = 3;
const int ledPin2 = 2;
const int ledPin3 = 7;
// variables will change:
int buttonState = 1; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);

void loop() {
// turn LED on:
digitalWrite(ledPin1, HIGH);
delay (10);
digitalWrite(ledPin1, LOW);
delay (10);
digitalWrite(ledPin3, HIGH);
delay (10);
digitalWrite(ledPin3, LOW);
delay (10);
digitalWrite(ledPin2, HIGH);
delay (10);
digitalWrite(ledPin2, LOW);
delay (10);


Here I tried blinking it only which you can see above

Then I tried programming fot blinking it only when switch is pressed which you can see below

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 8; // the number of the pushbutton pin
const int ledPin1 = 3;
const int ledPin2 = 2;
const int ledPin3 = 7;
// variables will change:
int buttonState = 1; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == LOW) {

// turn LED on:
digitalWrite(ledPin1, HIGH);
delay (200);
digitalWrite(ledPin1, LOW);
delay (200);
digitalWrite(ledPin3, HIGH);
delay (200);
digitalWrite(ledPin3, LOW);
delay (200);
delay (200);
digitalWrite(ledPin2, LOW);
delay (200);

} else {
// turn LED off:
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);

After program is written, it was compile and pushed to the board via the ISP we made in 4th week. You can see the video below.


Hex code generated is as below which is sent to the processor. This is very long as arduino IDE is comparatively high language than embedded c or assembly language



AVR-GCC is a compiler that takes C language high level code and creates a binary source which can be uploaded into an AVR micro controller. Thus AVR-GCC might be regarded as a 'C' cross compiler for producing AVR code. AVR-libc are 'C' run-time libraries, header files, and documentation primarily for the AVR target and are used in conjunction with AVR-GCC . Please note that AVR-libc and AVRLIB are different sets of libraries but both work with the AVR-GCC compiler. Once code in 'C' is written for a particular project AVR-GCC will turn C code into assembly language files. AVR-libc includes all the header files that contain the addresses of port and register names, the floating point library, AVR-specific macros, and AVR start-up code. It also provides a lot of documentation, both on the library items itself as well as on a number of general items on the entire tool chain, including a FAQ. Individual assembler files are then converted into object files. Object files are files of code that AVR chips could run. The linker AVR-ld will take all these assembler files, and cross-reference functions names to create one single object file. The linker will also take modules from the 'C' library and make them into a single object. Normally this linked object is in ELF format and furthermore AVR-objcopy is used to generate a HEX format file (

Installation, files for hex and flash

  1. First you should download a visual code studio from this link,
  2. Install it and goto
    View >> Extensions
    and search for c/c++, and install it.


  1. Now first thing you need to make is hex file that the IC can understand. You need a make file to convert it to hex file. First I used Linux OS. You have to save this file on the same location you have your program. Also set the frequency according to the resonator that you have. If the frequency is different from the specifications of you actual resonator, the time will change according to the value you enter so make sure it is correct.
  2. Write a program, start the terminal by clicking
            Terminal >> New Terminal 
  3. On the terminal type make hex which should create *.hex file, *.elf file and *.o file
  4. Now you have to flash your board using the following command which should send the upload the program into your board.
            avrdude -c usbtiny -pt84 -U flash:w:test.hex 
    (replace "test"in the code with your file name)


Since I mostly use Windows OS, I was thinking about installing AVRdue and AVR GCC on windows. Since I did not have prior experience and also learning, my teammate Saheen Palayi helped me to make it happen

  1. You need two files to make hex and to flash the program to the board
  2. For making hex file

Then for flashing the program


Time to program and flash

After knowing the process, I used the embedded c programming in visual studio code to blink the LED in the same board.


Save the program and replace the file name in the hex file and then a hex code is generated by using "hex.bat"


Hex code generated


Then after generating hex file, replace the file name in the flash file as well and the flashing was done using "flash.bat"


Then I tried adding a switch and then programmed as shown as below

#include //Opens the AVR library
#define F_CPU 20000000UL //Sets the frequency to be 20Mhz

int main()
int a = 100; //intialization for variable a with 100
DDRA |= (1 << 7); //Set PA7 as OUTPUT
DDRA |= (1 << 2); //Set PA2 as OUTPUT
DDRA |= (1 << 3); //Set PA3 as OUTPUT
DDRB &= ~(1 << 2); //Set PB2 as INPUT
PORTB |= (1<<2); //sets INPUT pin high

//Blinks all LED at once when connected
//Turns on the LED
PORTA |= (1 << 7); //Put high value at PA7
PORTA |= (1 << 3);
PORTA |= (1 << 2);
_delay_ms(a * 10); //delays for 1 sec
//Turns off the LED
PORTA &= ~(1 << 3);
PORTA &= ~(1 << 7);
PORTA &= ~(1 << 2);

while (1) //Infinite loop
if (!(PINB & (1<<2))) //checks PB2 is low or not
{ //blinks the LED
PORTA |= (1 << 7);
PORTA &= ~(1 << 3);
_delay_ms(a); //delays for 0.1sec
PORTA |= (1 << 2);
PORTA &= ~(1 << 7);
_delay_ms(a); //delays for 0.1sec
PORTA |= (1 << 3);
PORTA &= ~(1 << 2);
_delay_ms(a); //delays for 0.1sec
{ //turns off all LEDs
PORTA &= ~(1 << 7);
PORTA &= ~(1 << 3);
PORTA &= ~(1 << 2);

I tried different programs then to switch it on when clicked and switch off when again clicked. That means that each consecutive clicks would be inverting the state of LEDs. You can see the results below.


I came to know that the more high level language it is the longer is the hex code. As we can can Compare hex code generated by Arduino IDE with AVR GCC, the AVR GCC is shorter. Ardino is more easier to user which uses the code in the background.

Problems during this week

This week I had a problem with my board. I tried burning the bootloader with 20Mz which the resonator was supposed to be. Then it was not working. I need to then check what the actual problem was. then i followed following process

  1. Checked all the where the circuit board was OK or not using multimeter conituity test.
  2. Also checked if there is any short circuits in between
  3. Then I tried resholdering microcontroller, test it and resolder same resonator again which was still not working
  4. Then I tried replacing the board and it was working but as soon as I burn the bootloader, it was not working.
  5. Then I change the resonator and stuffed it in the board with soldering and checked with multimeter
  6. After burning the bootloader, it was working and I knew that is was the problem with the resonator

Group assignment

As a group assignment, we had to look after differet types of board and find out different architectures than AVR microcontrollers. For the comparison we had used the following Boards

  1. Raspberry Pi 4
  2. NodeMCU ESP8266
  3. Nucleo STM32F401
  4. Lattice Ice 40HX1K


ARM, previously Advanced RISC Machine, originally Acorn RISC Machine, is a family of reduced instruction set computing (RISC) architectures for computer processors, configured for various environments.Processors that have a RISC architecture typically require fewer transistors than those with a complex instruction set computing (CISC) architecture (such as the x86 processors found in most personal computers), which improves cost, power consumption, and heat dissipation. These characteristics are desirable for light, portable, battery-powered device-including smartphones, laptops and tablet computers, and other embedded systems.] For supercomputers, which consume large amounts of electricity, ARM could also be a power-efficient solution. Most of our mobile phones are based on ARM and now it used on server's and super controllers. Raspberry Pi is Single board computer that based on ARM.


Nucleo STM32F401

STM32 is a family of 32-bit microcontroller integrated circuits by STMicroelectronics. The STM32 chips are grouped into related series that are based around the same 32-bit ARM processor core, such as the Cortex-M7F, Cortex-M4F, Cortex-M3, Cortex-M0+, or Cortex-M0. Internally, each microcontroller consists of the processor core, static RAM memory, flash memory, debugging interface, and various peripherals. In here Fablab Kochi we have the STM32F401 series Nucleo development's a part of the STM32 Dynamic Efficiency™ device range. These devices offer the best balance of dynamic power consumption (in run mode) and processing performance, while integrating a high number of added-value features in packages as small as 3 x 3 mm. The MCUs deliver the performance of Cortex®-M4 core with floating point unit, running at 84 MHz, while achieving outstandingly low power consumption values in run and stop modes. You can know detail description in my teammate, Saheen Palayi's document.


NodeMCU ESP8266

The NodeMCU (Node MicroController Unit) is an open-source software and hardware development environment built around an inexpensive System-on-a-Chip (SoC) called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains the crucial elements of a computer: CPU, RAM, networking (WiFi), and even a modern operating system and SDK. That makes it an excellent choice for the Internet of Things (IoT) projects of all kinds. However, as a chip, the ESP8266 is also hard to access and use. You must solder wires, with the appropriate analog voltage, to its pins for the simplest tasks such as powering it on or sending a keystroke to the “computer” on the chip. You also have to program it in low-level machine instructions that can be interpreted by the chip hardware. This level of integration is not a problem using the ESP8266 as an embedded controller chip in mass-produced electronics. It is a huge burden for hobbyists, hackers, or students who want to experiment with it in their own IoT projects.To know more about NodeMCU please refer this this document form my Teammate Abhinav Ajith.


Lattice ICEstick Evaluation Board 40HX1K

Though we had to explore boards with different architectures, I woked with our goup to know about architectures as mentioned above and came up with this board which was different. This was the board which allows to set it to any architectures. This is called FPGA board meaning Field Programmable Gate Array. Field Programmable Gate Arrays (FPGAs) are semiconductor devices that are based around a matrix of configurable logic blocks (CLBs) connected via programmable interconnects. FPGAs can be reprogrammed to desired application or functionality requirements after manufacturing.

ICEstick Evaluation Board – features the following on-board components

  • High-performance, low-power iCE40HX1K FPGA
  • FTDI 2232H USB device allows iCE device programming and UART interface to a PC
  • Vishay TFDU4101 IrDA transceiver
  • Five user LEDs
  • 2 x 6 position Diligent PmodTM compatible connector enables many other peripheral connections
  • Discera 12Mhz MEMS oscillator
  • Micron 32Mbit N25Q32 SPI flash
  • Supported by Lattice iCEcube2™ design software
  • USB connector provides the power supply
  • 16 LVCMOS/LVTTL (3.3V) digital I/O connections on 0.1” through-hole connections

Block diagram

You can download the manual of the Lattice Ice 40HX1K in here.

The beauty of this board is that we can arrange this board in such any way we can. We can test any schematic and architecture in this board. This is a perfect device in which you can use to prototype the PCB and controllers. It contains array or electronic components which is connected according to your input and requirement without hassle of making new board.


You need two software to run it. First to arrange the array of the electronic components according to your requirement. We can use "iCEcube-2" to perform this operation. Then we can use other embedded programming language to flash the board.

Lattice Ice requires the preparation of two text files. The first is a *.v standard Verilog file. The second is a *.pcf pin assignment file that correlates the inputs and outputs declared in the Verilog code to the physical I/O pins on the FPGA.

[UPDATE] My colleague Saheen Palayi has done detail description about Lattice Ice 40HX1K in his documentation. Please click this link to access the documentation for the workflow.

Designed with Mobirise