1
0
mirror of https://github.com/sjlongland/atinysynth.git synced 2025-10-22 06:31:41 +10:00
atinysynth/ports/attiny861/Makefile
Stuart Longland f8346cdea9
Add ATTiny861 port.
The ATTiny85, as good as it is, has too few pins to really do a lot.
You can buy I²C GPIO expanders, but many cost more than programming an
ATTiny24A (which has more brains).

The nearest equivalent is the ATTiny861, it is basically the same core
as the ATTiny85, features the same PLL for high-speed PWM, but comes in
a 20-pin package.  They cost ~AU$3 in individual quantities.  (An
ATTiny85 costs AU$1.74, an ATTiny24A costs AU$1.57; thus you save about
20c and a lot of interfacing effort in going to the '861.)

Thus it can interface to 8 individual switches with ease.

The circuit here uses a 74374 D-latch to drive up to 8 LEDs with PWM and
two 4066s to isolate the 8 inputs.  Idea being, when the GPIO_EN signal
is high, the 4066s are turned on and port A sees the 8 GPIO lines on the
other side of the 4066s.

4066s were used because I have 4066s up the wazoo… bought a box of
random ICs off eBay many years ago and it came with 5 (!) tubes of
MM74HC4066s with 25 ICs each (amongst other parts, some hard-to-find).
The bonus being these can be ADC inputs too if desired, allowing sensing
of piezo sensors.

When we want to switch which LEDs are turned on, we bring GPIO_EN low,
switch port A's pins to outputs, assert the desired LEDs, then bring
GPIO_EN high again.  The 74374 latches those pins, and we are free to
put port A back to being inputs.

This happens with each sample from the synthesizer, alternating between
input and output.  Thus the effective rate seen on the LEDs and inputs
is half the sample rate.

A spare GPIO is available for turning on and off an amplifier (I use the
NJR NJM2113D) to save power.

The 74374's nOE pin is connected to the PWM output for the lights, thus
using pull resistors, one is able to use the one PWM channel for all 8
lights.  The lights are turned on in round-robin fashion, so effective
duty cycle is ⅛ and the refresh rate is ~500Hz.
2017-05-20 20:48:19 +10:00

39 lines
1.1 KiB
Makefile

CROSS_COMPILE ?= avr-
MCU ?= attiny861
CFLAGS ?= -g -mmcu=$(MCU) -O3 -Werror -Woverflow
CPPFLAGS ?= -I$(SRCDIR) -DF_CPU=$(FREQ) -DSYNTH_CFG=\"poly_cfg.h\"
LDFLAGS ?= -mmcu=$(MCU) -O3 -Wl,--as-needed
PROG ?= avrdude
PROG_ARGS ?= -B 10 -c stk500v2 -P /dev/ttyACM0
PROG_DEV ?= t861
TARGET=$(BINDIR)/synth.ihex
INCLUDES += -I$(SRCDIR) -I$(PORTDIR)
OBJECTS += $(OBJDIR)/main.o
# Low fuse:
# CLKDIV8=1 : 0x80 : Do not divide clock by 8
# CLKOUT=1 : 0x40 : Do not enable CLKOUT
# SUT=2 : 0x20 : Default start-up time
# CKSEL=1 : 0x01 : Use 16MHz PLL-derived clock
LFUSE=0xc1
# High fuse:
# RSTDISBL=1 : 0x80 : Enable external reset
# DWEN=1 : 0x40 : Disable DebugWire
# SPIEN=0 : 0x00 : Enable SPI programming
# WDTON=1 : 0x10 : Disable watchdog
# EESAVE=1 : 0x08 : EEPROM not preserved during erase
# BODLEVEL=7 : 0x07 : Brown-out detection disabled
HFUSE=0xdf
# Extended fuse:
# SELFPRGEN=unprogrammed : Disable self programming
EFUSE=0xff
FREQ=16000000
all: $(TARGET)
program: $(BINDIR)/synth.ihex
$(PROG) $(PROG_ARGS) -p $(PROG_DEV) -U flash:w:$^:i \
-U lfuse:w:$(LFUSE):m \
-U hfuse:w:$(HFUSE):m \
-U efuse:w:$(EFUSE):m