Week 8: Embedded programming

Assignement

For this assignment the objective was to read the datasheet of a microcontroller and program the board we made in the week 6's assignment to do something.

In week 6 assignment we used an ATtiny45, I read its datasheet found here.

Microcontroller features
  • High perfomance, Low Power AVR 8-bit microcontroller

  • Advanced RISC architecture

    • 120 powerful instructions

    • 32 x 8 general purpose working registers

  • Non-volatile Program and Data memories

    • 4K bytes of in-system programmable prgram memory flash

    • 256 bytes in-system programmable EEPROM

    • 256 bytes internal SRAM

  • Peripheral features

    • 8-bit Timer/Counter with prescaler and 2 PWM channels

    • USI - Universal Serial Interface with start condition detector

    • 10-bit ADC

    • Progammable Watchdog Timer

    • On-chip analog comparator

  • Operating voltage

    • 1.8 - 5.5V for ATtiny45V
    • 2.7 - 5.5V for ATtiny45
  • Speed Grade

    • ATtiny45V: 0 - 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5V
    • ATtiny45: 0 - 10 MHz @ 2.7 - 5.5V, 0 - 20 MHz @ 4.5 - 5.5V

This image shows pin configuration of the ATtiny45.

Pin configuration

programming

Before I started to programming the ATtiny45 chip I had to add it in arduino IDE and to do so I followed this link which gives a step by step tutorial on how to do it.

To program the board I used Arduino IDE, below there is an image of the program I wrote for this work.

int LED = PB3;
int button = PB4;

void setup() {
    pinMode(LED, OUTPUT);
    pinMode(button, INPUT);
}

void loop() {
    int btnRead = digitalRead(button);

    if (btnRead == HIGH) {
        digitalWrite(LED, HIGH);
    }
    else {
        digitalWrite(LED, LOW);
    }
}

program

Programming with arduino IDE was fun, a colleague in FabLab recommended to look at programming the chip without using arduino framework only work with C language for embedded. I don't think I will be able to do it during this cycle of 2019 however I woould like to try it sometime.

This is the hero shot

The program and designs of the circuit made can be found here.