Start Bootstrap

Embedded programming

Week 8

microcontroller data sheet





The most important part when we start a project involving electronics is to have knowledge of the capabilities and incapacities of the components we are using.

For this it is important to see the data sheet of the components!





This week, we are programming an attiny44, the data sheet of it we can see here:

  • ATtiny24, ATtiny44, ATtiny84 Datasheet




  • The first page of the data sheet shows most of the information about the component.







    It is important to know the pins and the description of the pins, to understand where to place the LEDs and buttons, and the AVR and power.

    PROGRAMING ECHO HELLO-WORLD








    Now is the time to use my ISP to program the Hello-Word board I did on week 6 in electronics design.



    To program my hello-world I will use the Arduino program and the USBTinyISP I did in week 4.

    For this you need:

  • - Have the program Arduino, you can download on the page arduino.cc
  • Install USB drivers for FTDI - you can find the page here
  • Install drivers to recognize USBtinyISP - you can find in the page AVR programmer and SPI interface.
  • Download the Attiny libraries for board recognition on Arduino - you can find the libraries with the installation guide here.





  • 1

    Connect the USBTinyISP to the hello-world board through the idc cable and connect both cards to the computer.















    2

    Check if USBTinyISP is being recognized on the computer, so go to the "device manager on windows" or use the lsusb command.






















    3

    Open the arduino program and configure the board.

  • Tools > Board > Attiny 44
  • Tools > Processor > Attiny 44
  • Tools > Clock > External 20MHz (or in case of not having an external clock, put 8MHz internal)
  • Tools > Port > COM9 (choose the corresponding port)
  • Tools > Programmer > USBtinyISP



















  • 4

    Burn the bootloader




    5

    Run the example Blink to check if everything is working.

    CODE












    Now it's time to program the board


    Firstly, it is necessary to note which pins are connected to the two LEDs and the button on the board.


    The schematic next to it helps you understand the relationship between the output pins of attiny44 and the arduino pins.

  • The LEDs are connected to the pins: 6 and 7
  • The button is connected to pin 4


  • The idea is to make a basic digital reading that turns on and off the two LEDs connected to digital pin 6 and 7 by pressing a button attached to pin 4.




    The code I ran on the Arduino was:


  • week8_button_blink.ino _Arduino Files



  • The programming went well, and both LEDs blink when you click the button. As we can see from the video below.

    VIDEO

    Copyright © FabAcademy 2017