-  Week 8  +

embedded programming

Tasks

  • Read a microcontroller data sheet
  • Program your board to do something, with as many different programming languages and programming environments as possible
  • Workflow

    For this week’s assignment, I decided to read the the Microcontroller Datasheet of Atmel’s Attiny44 chip.

    A lot was gained from reading it, but for me, some of the relevant information is:
    The pinout of the IC that maps all the relevant pins.

    Also, I came to know that the PortB pin is the digital-only i/o pins. Whereas the PortA pins have internal ADC which enables them to read and write digital as well as analog data. Also it enables them to act as SPI, pin-change interrupt, analog comparator etc.

    I also came to know the arduino pin mapping of the attiny44 chip via searching online and I made a handy diagram for myself for reference.

    Here are the steps that I followed to program the redesigned hello.echo board.

    Step 1: Making uno as isp

    I decided to use Arduino as ISP for programming. For that, I navigated to
          File > Examples > 11.ArduinoISP > ArduinoISP

    Step 2: Uncomment

    I had to use the old style wiring, and to do that, I had to uncomment a line in the code.

    Step 3: Uncommented

    After uncommenting, I could use the familiar style of wiring with MOSI at pin 11, MISO at pin 12, SCK at pin 13 and RESET at pin 10. Now I uploaded this ISP sketch to Arduino UNO with the following settings:
          Board: Arduino UNO
          Port: COM7 (could be a different port for a different board and different computer)
          Programmer: AVRISP mkII

    Step 4: Starting point of coding

    For my code, I decided to use and build upon example Blink sketch from
          File > Examples > 01.Basics > Blink

    Step 5: Arduino coding

    The code defines A7 (PA7 in the datasheet) as an input pin, to which a pushbutton is attached. The digital pin 3 is attached as an output pin to an LED with a current limiting resistor. The code turns the LED on when the button is pressed and then turns it off when the button is released. This is done by using an if statement that checks if the button is pressed or not and accordingly turns the LED on or off.

    Step 6: Choose attiny44

    Now, to program the attiny44 chip, I first go to Tools > Board > ATtiny24/44/84

    Step 7: Choose processor attiny44

    Next, I select Tools > Processor > ATtiny44

    Step 8: Choose external 20MHz

    Next, I choose Tools > Clock > External 20 MHz

    Step 9: Choose arduino com port

    After that, I chose the COM port that is connected to Arduino UNO, which in my case was COM7.

    Step 10: Arduino as isp

    And finally I chose the Tools > Programmer > Arduino as ISP as my programmer for the ATtiny44.

    Step 11: Burn bootloader

    After all these settings, I clicked on Tools > Burn Bootloader to burn the bootloader to the ATtiny44 with the given settings.

    Step 12: After that I went to Sketch > Upload, and uploaded the code to the board.

    The result of the code can be seen in the video below:

    After this, I modified the code such that the LED blinks at a set frequency, and when one presses the button, it will pause in whatever state the LED is in. It does so by recording the state of the LED and alternating it at each loop cycle. Then when the button is pressed, it remembers the state the LED was in at the time of pressing and continues to maintain that state until the button is released. Once the button is released, the LED resumes blinking at the set frequency.

    The demonstration of the code can be seen in another video here:

    Note: A basic sketch, designed by Scott Fitzgerald was used to test the board. It is modified to verify the operation of button and LED. Finally, I have tired to code the button which acts as a pause switch for a blinking LED pattern. Since, I did not have a system to work on, I have been working on workstations of Mohit Ahuja, Siddharth Arya, Avishek Das and FabLab Cept. I would like to acknowledged their efforts and thank them for their kindness.

    Links

    Week 8 Files