Skip to content

Commit

Permalink
New version, works with external pull-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
shimaore committed Mar 18, 2013
1 parent b7cbee7 commit cde45e7
Show file tree
Hide file tree
Showing 2 changed files with 388 additions and 65 deletions.
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
CC=avr-gcc
LD=avr-ld
MCU_TARGET=attiny2313a
DUDE_TARGET=attiny2313
AVRDUDE=avrdude
PORT=/dev/ttyUSB0
override CFLAGS=-Wall -g -Os -mmcu=${MCU_TARGET}
override LDFLAGS=

%.o: %.c
${CC} ${CFLAGS} -c $<

%.elf: %.o
${LD} ${LDFLAGS} -Map $@.map -o $@ $< /usr/lib/avr/lib/libc.a /usr/lib/avr/lib/avr25/crttn2313a.o

%.lst: %.elf
avr-objdump -h -S $< > $@

%.lst: %.o
avr-objdump -h -S $< > $@

%.hex: %.elf
avr-objcopy -j .text -j .data -O ihex $< $@

program-%: %.hex
# Write code out
${AVRDUDE} -p ${DUDE_TARGET} -P ${PORT} -U flash:w:$<

clean:
rm -f *.o *.elf *.elf.map *.lst *.hex

# Project-specific
install: program-paul_1

erase:
${AVRDUDE} -p ${DUDE_TARGET} -P ${PORT} -e

show-fuses:
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U lfuse:r:/dev/stdout:h
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U hfuse:r:/dev/stdout:h
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U efuse:r:/dev/stdout:h

set-fuse:
# Nothing to do here.

clear-fuse:
# Note: bit=1 means "unprogrammed", bit=0 means "programmed"

# This is the default: internal 8MHz clock divided by 8 = 1MHz clock
# Divide clock by 8
# |Output clock on CKOUT
# ||SUT1
# |||SUT0
# ||||CKSEL3
# |||||CKSEL2
# ||||||CKSEL1
# |||||||CKSEL0
# ||||||||
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U lfuse:w:0b01100100:m

# DebugWire
# |EESAVE
# ||SPIEN
# |||WDTON
# ||||BODLEVEL2
# |||||BODLEVEL1
# ||||||BODLEVEL0
# |||||||RSTDISBL
# ||||||||
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U hfuse:w:0b11011111:m
# Default: BOD disabled

# SELFPRGEN
# |
${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -U efuse:w:0b11111111:m
# Self Programming: disabled

high-speed:
echo sck 8.68 | ${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -t

slow-speed:
echo sck 276.7 | ${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -t -F

voltage:
echo vtarg 3.0 | ${AVRDUDE} -p ${DUDE_TARGET} -P /dev/ttyUSB0 -t -F

all: slow-speed clear-fuse high-speed install set-fuse
Loading

0 comments on commit cde45e7

Please sign in to comment.