Week 7: Embedded programming

Programming the ATTINY44 with an LED and a button

Here is the sequence:

Stuffed board. This is what I made two weeks earlier

components

I used David Mellis' instructions to upload the Arduino ISP sketch to an Arduino UNO thereby converting it in to an STK500v1 programmer. I used this and the arduino IDE to upload a blink sketch to the ATTINY44 board. The ATTINY support for arduino is added according to David Mellis' page

components

Blinking program

LED controlled by button program

Then I tried programming the same two behaviors using WinAVR and avrdude. I had to load a c program in to winavr and write a makefile using the mfile program. In Winavr, once the c program is written and the makefile with the right settings is written, do this:

Tools -> Make All

Tools -> Make Clean

Tools -> Make Program

These are setting in the Makefile when using the Arduino ISP to program the Attiny44 with a 20Mhz external oscillator

TARGET = main

AVRDUDE_PROGRAMMER = stk500v1

MCU = attiny44

AVRDUDE_PORT = com5

F_CPU = 20000000

change baud rate to 19200 in this line AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -b 19200 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)

If using Avrdude on command line, once the hex file is written, run:

avrdude -p attiny44 -P com5 -c stk500v1 -b 19200 -U flash:w:main.hex

CAVEATS:

Baud rate must be -19200 or whatever the programmer's baud rate is. 19200 was set when the ArduinoISP sketch was uploaded to the ArduinoUno under Serial.print(19200) Programmer must be stk500v1, not stk500 or stk500v2 when using avrdude and the ArduinoISP Port needs to be the correct port number. May be check on the Arduino interface

Blink program

components

Button program

components

Finally I tested serial communication using the python program term.py

components