Contact:

E-mail: franco.robredo@gmail.com

 

Franco Robredo Bretón

Mechanical Engineer

 

Week nine: Embedded programming

I read the Attiny 45 datasheet and used it to understand what pins I can use for digital and analog means, I also found the image in the left wich was really usefull, to download the datasheet and the pinout diagram click on the image.

It was all very interesting but something that really caught my eye was the capacitive touch sensing library that Atmel offers.

 

Also the data retention reliability is really good, I never thought that would be a measured specificaction.

 

Programming in arduino

This week I programmed a blink in Arduino and in Atmel Studio and using my programmer from week five I uploaded it to my circuit from week seven.

 

The first thing to do is to install the driver so the computer knows how to read the ATtiny 45 in the programmer board, you can get the driver in this page: https://learn.adafruit.com/usbtinyisp/drivers

 

Then we need to install Arduino from the oficial page.

 

Then I went to this page: https://playground.arduino.cc/Main/ArduinoOnOtherAtmelChips and searched

for my ATtiny 45 URL, copy the URL and paste it in preferences add boards. Then just look for your board like you would normally do in Arduino.

I'ts really important that you check the box in preferences "show compilation" so you can copy the direction where your .hex file is being stored. I recomend you copy the file and paste it on your desktop because it will be easier to find the file from cmd prompt later.

 

Write your program, compile it and search in the bottom of the page the direction where your .hex file was written.

 

Untill this part you only use Arduino, now I'll show you how to do the same but from

Atmel Studio and then I'll explain how to upload both programs from cmd prompt using avrdude.

This is the program I used from arduino, it is the button example, you can find it in files>examples>digital>button or you can click below to download it.

With that information I could show my mastery in programming by building a program from scratch that took me about 3 minutes to write. It is an SOS signal in morse code displayed in my arduino mega's built in led.

Programming in Atmel Studio.

First you need to start a new project and click on executable project, then you choose your device, for me it was the ATtiny 45, write your code and compile it by clicking "Build" and "compile".

 

Go to the bottom of the page and search for the location of the folder in wich your .hex file was written.

 

Just as in Arduino I recomend copying the file to your desktop and changing the name to something you can remember.

Open cmd prompt and write "cd desktop" to access the files in your desktop, then write "avrdude -c usbtiny -p t45 -U flash:w:(name of your file).hex"

 

Ok so to explain a bit, by writing avrdude you are calling the program avrdude (obviously), the "-c" is for specifying the programmer which in my case is an "usbtiny, the "-p is for the part number or the type of device which is "t45" for the ATtiny 45, the "-U is to specify de memory type which can be "flash, RAM or EEPROM" and then between double points you specify what you want to do with the memory which can be "r" for reading, "w" for writing and "v" for viewing, in this case we're going to write the file of our program in the memory.