Close

ATtinys ready to go

A project log for EZeeSample

Shelved this one to work on other things - kept for sentimental reasons

johnowhitakerjohnowhitaker 04/26/2015 at 16:030 Comments

I have my tool-chain all set up. Tested it today by uploading the obligatory LED blinking program.

The code will be written in C, compiled with gcc-avr and uploaded with a bus pirate (my favourite tool of late) using avrdude -p attiny85 -c buspirate -P /dev/ttyUSB0.

Using the bus pirate as an AVR programmer is wonderful - no external components or power needed. I just connect +3.3V and GND to +V and GND on the 'tiny, wire up MOSI and MISO, CLK goes to SCK on the 'tiny and CS goes to RESET (pin 1 of the ATtiny85). Here is the makefile I use:

DEVICE     = attiny85
CLOCK      = 1000000
PROGRAMMER = -c buspirate -P /dev/ttyUSB0
OBJECTS    = main.o
FUSES      = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
# generated by http://www.engbedded.com/fusecalc/

AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)

all:	main.hex

.c.o:
	$(COMPILE) -c $< -o $@

.S.o:
	$(COMPILE) -x assembler-with-cpp -c $< -o $@

.c.s:
	$(COMPILE) -S $< -o $@

flash:	all
	$(AVRDUDE) -U flash:w:main.hex:i

fuse:
	$(AVRDUDE) $(FUSES)

install: flash fuse

load: all
	bootloadHID main.hex

clean:
	rm -f main.hex main.elf $(OBJECTS)

main.elf: $(OBJECTS)
	$(COMPILE) -o main.elf $(OBJECTS)

main.hex: main.elf
	rm -f main.hex
	avr-objcopy -j .text -j .data -O ihex main.elf main.hex

disasm:	main.elf
	avr-objdump -d main.elf

cpp:
	$(COMPILE) -E main.c

Nice to have everything ready, so now I can get down to prototyping. I also plan on whipping up a PCB during my next Altium lecture (uni student, so free access) although I am tempted to go with Kicad. The only reason I'm considering Altium is that this project will probably be simple enough for others to reproduce just by looking at the schematic, and I need the practice...

Discussions