This week's assignment was to read a datasheet and program the echo hello world board to do something. I was away for a conference this week and then the semester has been kinda crazy that I didn't get to make up for this week until much later. I decided to use this week's assingment to design and program the board I need for my final project. I didn't use the echo hello world board because it only had a LED as output and no input, I thought I should just use the attiny processor and program a board with more components.
There are couple ways you can program an ATtiny. I tried using avrdude and Arduino. You can use avrdude like how I did in week 3 and 5. I documented how to set up the environment in week 3. To use the Arduino IDE, you need to download the extension for attiny and learn how the pins on attiny correspond to arduino pins. This tutorial gives a nice walk-through of how to programm a attiny with Arduino IDE. I was able to program my chip with Arduino IDE but I think the pinout was off even though I followed the tutorial above and other people who have used the same pinout got it to work. I switched back to avrdude while I'm trying to figure out the problem.
To use avrdude, you will need a makefile and code in c. The makefile tells the programmer how to set up and program things. I started with Neil's makefile and modified it to program my board.I didn't know anything about C so I also started with Neil's code to understand how to do different things. This video recommended by Allan gives a good lesson on how to program in C, especially bit manipulation.
The schematic and board layout for the board can be found on the final presentation page. I used an ATtiny 44, which is very similar to ATtiny 45 used in echo hello world but has more pins. Here are the makefile and c code.
To load the program onto the board, cd into the directory with the makefile and the c code and run the following commands (you may need to do sudo make instead of make for the last two commands):
To compile the program: make -f makefile_name.make
To make the chip use the external clock (I didn't use an external clock so I didn't use this command): make -f makefile_name.make program-usbtiny-fuses
To upload the program into the chip: make -f makefile_name.make program-usbtiny
The first couple times I tried to upload the program, I got the scary rc=1 error. I also had that problem programming other boards. It's usually because of bad hardware connection (on either your board or the programmer). Checking your board with a multimeter is a good way to debug. Another thing to make is that you are powering your board from a power source, not from the programmer, e.g. I was powering it with a ftdi cable connected to my laptop. Another common error is Could not find USBtiny device. A way to check if the error comes from your board or the programmer is to probe the clock signal on the programmer when the programmer is trying to program and if there's no clock signal, it's probably because the programmer is not working.
After debugging for a while, the code was uploaded and the LEDs turned on!