Skip to content

Commit 1eee15a

Browse files
committed
Get bare ATtiny85 process working
wuddadoozy 1. Lots of issues despite Digispark, which uses 10mhz attiny85 in SMD format, working fine. 2. Tiny AVR Programmer wasn't responsive and no blinking lights anywhere, even though multimeter confirmed chip was getting power. Trying the actual Damellis/ATtiny board Sparkfun recommends in the hookup guide seemed to get it working. Able to upload blink 3. Uploaded game code and looked like it was blinking at about the same rate as blink example. Why? 4. On top of that, silent speaker output. Tried 386 and different pins. Turns out the "ATtiny" core doesn't have tone() implemented, just fails silently. Switched back to the "SpenceKonde/ATTinyCore" I had originally... 5. Oh! ATTinyCore has lots of unfamiliar options, and that's why I couldn't get it working originally. It turns out I also had the wrong programmer selected. Needed to be "USBtinyISP (ATTinyCore) SLOW, for new or 1MHz parts". TODO: understand the difference 6. Once ATTinyCore started uploading, timing was super duper slow. Options were guess-and-check to dial in, exacerbated by the IDE's unquittable, long failure cycle. 1mhz is good. 8 and 16mhz were too slow. TODO: understand, check if frequencies are the same as arduboy 7. Final gotcha was getting CLI to work instead of the IDE. Seems like arduino-cli doesn't support the Tiny AVR Programmer, which doesn't use a dedicated port? My solution was to copy the avrdude stuff the Scout burner used. There may be a better workardound mentioned here: https://forum.arduino.cc/t/how-install-attiny-cores-for-arduino-cli/690928/2 In summary, combination issue of programmer unfamiliarity and inconsistent tone() support across core libraries. Other notes: - The author suggests using pin 4 for speaker for better tone() performance. Doesn't seem to make a discernible difference in my tests but there's no harm in switching. - Pullups were indeed not necessary. The chip's on-board pulls work just fine. Must've been a breadboard/board problem.
1 parent 6b0c526 commit 1eee15a

File tree

6 files changed

+58
-126
lines changed

6 files changed

+58
-126
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ build/
22
local/
33
imgui.ini
44
.vscode/
5-
kicad/*-backups/
5+
6+
kicad/*-backups/
7+
kicad/#auto_saved_files#

arduino/higher_lower/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifdef __AVR_ATtiny85__
2-
#define SPKR_PIN 0
2+
#define SPKR_PIN 4
33
#define LED_PIN 1
44
#define UP_BUTTON 2
55
#define DOWN_BUTTON 3
6-
#define SKIP_BUTTON 4
6+
#define SKIP_BUTTON 0
77
#else
88
#define SPKR_PIN 5
99
#define LED_PIN 9

arduino/higher_lower/higher_lower.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void increment() { index = constrain(index + 1, 0, TONES_COUNT - 1); }
8484

8585
void handleGuess(bool success) {
8686
if (success) {
87-
// TODO: round ending prematurely (hardware only?)
8887
if (index == TONES_COUNT - 1) {
8988
playSuccessSound(currentRound + 1);
9089
delay(NEW_ROUND_PAUSE);

arduino/higher_lower/interface.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ void setupInterface() {
66
pinMode(LED_PIN, OUTPUT);
77
digitalWrite(LED_PIN, LOW);
88

9-
// ATtiny85 says it has pullups but in practice may not?
10-
// Seems like it might be a digispark/breadboard issue.
11-
// TODO: Try different breadboard. Try bare ATtiny85.
129
pinMode(UP_BUTTON, INPUT_PULLUP);
1310
pinMode(DOWN_BUTTON, INPUT_PULLUP);
1411
pinMode(SKIP_BUTTON, INPUT_PULLUP);

kicad/higher_lower.kicad_sch

Lines changed: 32 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@
507507
508508
(no_connect (at 152.4 101.6) (uuid 803a6ac3-81da-4e1b-a625-4e5e5497c2ce))
509509
510-
(wire (pts (xy 184.15 113.03) (xy 184.15 114.935))
510+
(wire (pts (xy 191.135 113.03) (xy 191.135 114.935))
511511
(stroke (width 0) (type default) (color 0 0 0 0))
512512
(uuid 07560b1f-66f2-4410-a3ae-2efec6e686c0)
513513
)
@@ -527,22 +527,18 @@
527527
(stroke (width 0) (type default) (color 0 0 0 0))
528528
(uuid 1ec5cab1-8dc6-49cd-a7ce-c0e2c3830170)
529529
)
530-
(wire (pts (xy 124.46 111.76) (xy 124.46 114.935))
530+
(wire (pts (xy 191.135 103.505) (xy 196.85 103.505))
531531
(stroke (width 0) (type default) (color 0 0 0 0))
532-
(uuid 25b849f2-a026-4dff-9231-d914bd821356)
532+
(uuid 22ee8ef8-f52a-45ab-becc-c51d7fbb514a)
533533
)
534-
(wire (pts (xy 184.15 92.075) (xy 188.595 92.075))
534+
(wire (pts (xy 124.46 111.76) (xy 124.46 114.935))
535535
(stroke (width 0) (type default) (color 0 0 0 0))
536-
(uuid 49e2e0d0-6448-49d1-a820-16d97efaf3c4)
536+
(uuid 25b849f2-a026-4dff-9231-d914bd821356)
537537
)
538-
(wire (pts (xy 184.15 101.6) (xy 184.15 103.505))
538+
(wire (pts (xy 191.135 101.6) (xy 191.135 103.505))
539539
(stroke (width 0) (type default) (color 0 0 0 0))
540540
(uuid 4ac7d5d2-31a8-43d3-9e58-aa7cecf03d51)
541541
)
542-
(wire (pts (xy 193.675 92.075) (xy 196.85 92.075))
543-
(stroke (width 0) (type default) (color 0 0 0 0))
544-
(uuid 4dd54627-dfcb-4cc1-94cf-f232ee892108)
545-
)
546542
(wire (pts (xy 219.71 66.675) (xy 219.71 64.77))
547543
(stroke (width 0) (type default) (color 0 0 0 0))
548544
(uuid 50253220-63c0-4df2-87e1-b759d535f6c0)
@@ -551,18 +547,10 @@
551547
(stroke (width 0) (type default) (color 0 0 0 0))
552548
(uuid 6a1eb119-741e-4821-9067-21871543ce75)
553549
)
554-
(wire (pts (xy 193.675 103.505) (xy 196.85 103.505))
555-
(stroke (width 0) (type default) (color 0 0 0 0))
556-
(uuid 8ea07948-77b4-4e68-9033-48179b871603)
557-
)
558550
(wire (pts (xy 219.71 64.77) (xy 210.185 64.77))
559551
(stroke (width 0) (type default) (color 0 0 0 0))
560552
(uuid 90ecf332-a0bf-4e40-af08-7106a484ee72)
561553
)
562-
(wire (pts (xy 184.15 103.505) (xy 188.595 103.505))
563-
(stroke (width 0) (type default) (color 0 0 0 0))
564-
(uuid 96c44b97-186d-4195-bd78-e1a19bdf0ca1)
565-
)
566554
(wire (pts (xy 198.755 64.77) (xy 205.105 64.77))
567555
(stroke (width 0) (type default) (color 0 0 0 0))
568556
(uuid 9cdd89f3-a4b9-4830-a0b5-414d8dd774b2)
@@ -571,11 +559,7 @@
571559
(stroke (width 0) (type default) (color 0 0 0 0))
572560
(uuid a0067bc2-0f18-43f0-a5b9-f529af71f014)
573561
)
574-
(wire (pts (xy 193.675 114.935) (xy 196.85 114.935))
575-
(stroke (width 0) (type default) (color 0 0 0 0))
576-
(uuid a487e012-1e00-4136-ab9a-ac674e4ebca5)
577-
)
578-
(wire (pts (xy 184.15 90.17) (xy 184.15 92.075))
562+
(wire (pts (xy 191.135 90.17) (xy 191.135 92.075))
579563
(stroke (width 0) (type default) (color 0 0 0 0))
580564
(uuid ac59ceb1-9613-45b9-a7a2-1dc464fc8d48)
581565
)
@@ -603,14 +587,18 @@
603587
(stroke (width 0) (type default) (color 0 0 0 0))
604588
(uuid d10fed4b-9a5f-462f-82e5-322cb681a193)
605589
)
606-
(wire (pts (xy 184.15 114.935) (xy 188.595 114.935))
590+
(wire (pts (xy 191.135 92.075) (xy 196.85 92.075))
607591
(stroke (width 0) (type default) (color 0 0 0 0))
608-
(uuid e78e9404-d170-4e3d-9ed2-d5cb6020d102)
592+
(uuid e15dbd82-92e0-4f2b-8b78-a1bce3181419)
609593
)
610594
(wire (pts (xy 139.7 91.44) (xy 152.4 91.44))
611595
(stroke (width 0) (type default) (color 0 0 0 0))
612596
(uuid f0a09528-957b-496e-b2b2-5b2e4ef534c5)
613597
)
598+
(wire (pts (xy 191.135 114.935) (xy 196.85 114.935))
599+
(stroke (width 0) (type default) (color 0 0 0 0))
600+
(uuid f4123535-8722-4c87-8b4b-05782cbf9e36)
601+
)
614602
(wire (pts (xy 207.01 114.935) (xy 210.82 114.935))
615603
(stroke (width 0) (type default) (color 0 0 0 0))
616604
(uuid f8c2d073-a162-46b7-845d-da0d914f87e4)
@@ -624,10 +612,6 @@
624612
(effects (font (size 1.27 1.27)) (justify left bottom))
625613
(uuid 1131aedc-bdf4-4821-bf60-92cf6c7d3fda)
626614
)
627-
(text "TODO: ditch pull-ups?" (at 189.865 87.63 0)
628-
(effects (font (size 1.27 1.27)) (justify left bottom))
629-
(uuid bbbf04a5-3880-4668-8200-87e9e298f199)
630-
)
631615
(text "TODO: ditch" (at 208.915 120.015 0)
632616
(effects (font (size 1.27 1.27)) (justify left bottom))
633617
(uuid f7e45f83-0aa5-41be-89be-1f5fee850f46)
@@ -689,17 +673,17 @@
689673
(effects (font (size 1.27 1.27)) (justify left) hide)
690674
)
691675
)
692-
(global_label "OUTPUT" (shape input) (at 140.97 88.9 0) (fields_autoplaced)
676+
(global_label "SKIP" (shape input) (at 140.97 88.9 0) (fields_autoplaced)
693677
(effects (font (size 1.27 1.27)) (justify left))
694678
(uuid d7e48ff3-147e-4566-8af0-3deacbf76535)
695-
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 150.5798 88.8206 0)
679+
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 147.7374 88.8206 0)
696680
(effects (font (size 1.27 1.27)) (justify left) hide)
697681
)
698682
)
699-
(global_label "SKIP" (shape input) (at 140.97 99.06 0) (fields_autoplaced)
683+
(global_label "OUTPUT" (shape input) (at 140.97 99.06 0) (fields_autoplaced)
700684
(effects (font (size 1.27 1.27)) (justify left))
701685
(uuid f1695ae4-b795-49e8-824a-4ac5c8379df2)
702-
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 147.7374 98.9806 0)
686+
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 150.5798 98.9806 0)
703687
(effects (font (size 1.27 1.27)) (justify left) hide)
704688
)
705689
)
@@ -739,17 +723,17 @@
739723
(pin "1" (uuid b7cf9fe2-e3ec-4ae0-bebd-cf7e96f30085))
740724
)
741725
742-
(symbol (lib_id "power:VCC") (at 184.15 101.6 0) (unit 1)
726+
(symbol (lib_id "power:VCC") (at 191.135 101.6 0) (unit 1)
743727
(in_bom yes) (on_board yes)
744728
(uuid 1a4b987f-1438-498c-b297-956f8fc4560b)
745-
(property "Reference" "#PWR08" (id 0) (at 184.15 105.41 0)
729+
(property "Reference" "#PWR08" (id 0) (at 191.135 105.41 0)
746730
(effects (font (size 1.27 1.27)) hide)
747731
)
748-
(property "Value" "VCC" (id 1) (at 184.15 97.79 0))
749-
(property "Footprint" "" (id 2) (at 184.15 101.6 0)
732+
(property "Value" "VCC" (id 1) (at 191.135 97.79 0))
733+
(property "Footprint" "" (id 2) (at 191.135 101.6 0)
750734
(effects (font (size 1.27 1.27)) hide)
751735
)
752-
(property "Datasheet" "" (id 3) (at 184.15 101.6 0)
736+
(property "Datasheet" "" (id 3) (at 191.135 101.6 0)
753737
(effects (font (size 1.27 1.27)) hide)
754738
)
755739
(pin "1" (uuid 960e8759-b27f-484b-876e-3ff034b27162))
@@ -861,36 +845,6 @@
861845
(pin "2" (uuid 72d964a1-319b-459f-bdf9-895f9d32cf8f))
862846
)
863847
864-
(symbol (lib_id "Device:R_Small_US") (at 191.135 92.075 270) (unit 1)
865-
(in_bom yes) (on_board yes)
866-
(uuid 79bfbe14-a298-49a3-af8d-2c4745d625ef)
867-
(property "Reference" "R2" (id 0) (at 191.135 95.25 90))
868-
(property "Value" "10k" (id 1) (at 191.135 97.79 90))
869-
(property "Footprint" "" (id 2) (at 191.135 92.075 0)
870-
(effects (font (size 1.27 1.27)) hide)
871-
)
872-
(property "Datasheet" "~" (id 3) (at 191.135 92.075 0)
873-
(effects (font (size 1.27 1.27)) hide)
874-
)
875-
(pin "1" (uuid 75701bd8-7de1-49fe-a80f-06a036d326ad))
876-
(pin "2" (uuid 4d68ba8b-b167-477c-86f2-c1a693bf5cb9))
877-
)
878-
879-
(symbol (lib_id "Device:R_Small_US") (at 191.135 114.935 270) (unit 1)
880-
(in_bom yes) (on_board yes)
881-
(uuid 8156c135-b1d2-4bd5-8adf-080c2f73b8d5)
882-
(property "Reference" "R4" (id 0) (at 191.135 118.11 90))
883-
(property "Value" "10k" (id 1) (at 191.135 120.65 90))
884-
(property "Footprint" "" (id 2) (at 191.135 114.935 0)
885-
(effects (font (size 1.27 1.27)) hide)
886-
)
887-
(property "Datasheet" "~" (id 3) (at 191.135 114.935 0)
888-
(effects (font (size 1.27 1.27)) hide)
889-
)
890-
(pin "1" (uuid 37d4713c-d829-47c7-9809-86256e2969f9))
891-
(pin "2" (uuid a8b587a1-2f6e-4cdd-8acb-13e60b639b96))
892-
)
893-
894848
(symbol (lib_id "power:GND") (at 208.915 144.145 0) (unit 1)
895849
(in_bom yes) (on_board yes)
896850
(uuid 8d28cc8d-0b90-4463-b6e2-6b5f52b486a0)
@@ -924,17 +878,17 @@
924878
(pin "2" (uuid 612a87b9-3353-4247-bb15-c64508fb662e))
925879
)
926880
927-
(symbol (lib_id "power:VCC") (at 184.15 113.03 0) (unit 1)
881+
(symbol (lib_id "power:VCC") (at 191.135 113.03 0) (unit 1)
928882
(in_bom yes) (on_board yes)
929883
(uuid 98ce1880-8f29-4dd9-8413-8c97fba3f6db)
930-
(property "Reference" "#PWR09" (id 0) (at 184.15 116.84 0)
884+
(property "Reference" "#PWR09" (id 0) (at 191.135 116.84 0)
931885
(effects (font (size 1.27 1.27)) hide)
932886
)
933-
(property "Value" "VCC" (id 1) (at 184.15 109.22 0))
934-
(property "Footprint" "" (id 2) (at 184.15 113.03 0)
887+
(property "Value" "VCC" (id 1) (at 191.135 109.22 0))
888+
(property "Footprint" "" (id 2) (at 191.135 113.03 0)
935889
(effects (font (size 1.27 1.27)) hide)
936890
)
937-
(property "Datasheet" "" (id 3) (at 184.15 113.03 0)
891+
(property "Datasheet" "" (id 3) (at 191.135 113.03 0)
938892
(effects (font (size 1.27 1.27)) hide)
939893
)
940894
(pin "1" (uuid 848a05cf-9f2d-4924-8de5-2142bbaa275e))
@@ -987,21 +941,6 @@
987941
(pin "1" (uuid bf813ca6-c9b0-496b-a4b2-6cd15e7fa5b4))
988942
)
989943
990-
(symbol (lib_id "Device:R_Small_US") (at 191.135 103.505 270) (unit 1)
991-
(in_bom yes) (on_board yes)
992-
(uuid bfb5ec4d-55e7-4dbe-ae47-620294c06820)
993-
(property "Reference" "R3" (id 0) (at 191.135 106.68 90))
994-
(property "Value" "10k" (id 1) (at 191.135 109.22 90))
995-
(property "Footprint" "" (id 2) (at 191.135 103.505 0)
996-
(effects (font (size 1.27 1.27)) hide)
997-
)
998-
(property "Datasheet" "~" (id 3) (at 191.135 103.505 0)
999-
(effects (font (size 1.27 1.27)) hide)
1000-
)
1001-
(pin "1" (uuid 7973fcb5-29bb-4147-a4ba-fabef29f8aa4))
1002-
(pin "2" (uuid e3020ed2-2f50-4016-bf3a-4c5ee3e0b539))
1003-
)
1004-
1005944
(symbol (lib_id "power:GND") (at 82.55 75.565 0) (unit 1)
1006945
(in_bom yes) (on_board yes)
1007946
(uuid d13700fa-0042-41b7-80bf-1ad40b704bab)
@@ -1064,17 +1003,17 @@
10641003
(pin "2" (uuid f6d879b0-69f8-4777-b983-7f38d2f5a23d))
10651004
)
10661005
1067-
(symbol (lib_id "power:VCC") (at 184.15 90.17 0) (unit 1)
1006+
(symbol (lib_id "power:VCC") (at 191.135 90.17 0) (unit 1)
10681007
(in_bom yes) (on_board yes)
10691008
(uuid f11eb872-feaa-41e1-9691-c44eb79ea70e)
1070-
(property "Reference" "#PWR07" (id 0) (at 184.15 93.98 0)
1009+
(property "Reference" "#PWR07" (id 0) (at 191.135 93.98 0)
10711010
(effects (font (size 1.27 1.27)) hide)
10721011
)
1073-
(property "Value" "VCC" (id 1) (at 184.15 86.36 0))
1074-
(property "Footprint" "" (id 2) (at 184.15 90.17 0)
1012+
(property "Value" "VCC" (id 1) (at 191.135 86.36 0))
1013+
(property "Footprint" "" (id 2) (at 191.135 90.17 0)
10751014
(effects (font (size 1.27 1.27)) hide)
10761015
)
1077-
(property "Datasheet" "" (id 3) (at 184.15 90.17 0)
1016+
(property "Datasheet" "" (id 3) (at 191.135 90.17 0)
10781017
(effects (font (size 1.27 1.27)) hide)
10791018
)
10801019
(pin "1" (uuid e5d2167d-3280-48c3-b510-422b5a4f7072))
@@ -1151,15 +1090,6 @@
11511090
(path "/f5fcb4f8-422e-4c2e-bb1f-9689e74188c5"
11521091
(reference "R1") (unit 1) (value "220") (footprint "")
11531092
)
1154-
(path "/79bfbe14-a298-49a3-af8d-2c4745d625ef"
1155-
(reference "R2") (unit 1) (value "10k") (footprint "")
1156-
)
1157-
(path "/bfb5ec4d-55e7-4dbe-ae47-620294c06820"
1158-
(reference "R3") (unit 1) (value "10k") (footprint "")
1159-
)
1160-
(path "/8156c135-b1d2-4bd5-8adf-080c2f73b8d5"
1161-
(reference "R4") (unit 1) (value "10k") (footprint "")
1162-
)
11631093
(path "/ee12aa8c-531a-4fb4-abd1-5e630092c7cd"
11641094
(reference "SW1") (unit 1) (value "SW_SPST") (footprint "")
11651095
)

run.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
set -o errexit
77
set -o errtrace
88

9+
_packages="$HOME/Library/Arduino15/packages"
10+
avrdude="${_packages}/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude"
11+
avrdude_config="${_packages}/ATTinyCore/hardware/avr/1.5.2/avrdude.conf"
12+
913
ardens="/Applications/Ardens/Ardens.app/Contents/MacOS/Ardens"
1014

1115
port="/dev/cu.usbmodem143101"
@@ -14,7 +18,7 @@ stub=$(ls arduino | xargs)
1418
input_path="$PWD/arduino/${stub}"
1519

1620
arduboy_build_dir="$PWD/build/arduboy"
17-
digispark_build_dir="$PWD/build/digispark"
21+
attiny85_build_dir="$PWD/build/attiny85"
1822

1923
function help() {
2024
echo "\
@@ -54,15 +58,14 @@ function compile_for_arduboy() {
5458
echo
5559
}
5660

57-
function compile_for_digispark() {
58-
echo "COMPILING FOR DIGISPARK"
61+
function compile_for_attiny85() {
62+
echo "COMPILING FOR ATTINY85"
5963
echo
6064

61-
mkdir -pv "${digispark_build_dir}" >/dev/null
65+
mkdir -pv "${attiny85_build_dir}" >/dev/null
6266
arduino-cli compile \
63-
--fqbn "digistump:avr:digispark-tiny" \
64-
--build-path="$digispark_build_dir" \
65-
--build-property "compiler.cpp.extra_flags=-w" \
67+
--fqbn "ATTinyCore:avr:attinyx5:clock=4internal" \
68+
--build-path="$attiny85_build_dir" \
6669
"${input_path}"
6770

6871
echo
@@ -72,16 +75,17 @@ function emulate() {
7275
$ardens file="${arduboy_build_dir}/${stub}.ino.hex"
7376
}
7477

75-
function upload_to_digispark() {
78+
function upload_with_programmer() {
7679
echo "UPLOADING"
7780
echo
7881

79-
echo "If already plugged in, unplug/reset/de-breadboard digispark..."
80-
echo
81-
82-
arduino-cli upload \
83-
--fqbn "digistump:avr:digispark-tiny" \
84-
--input-dir "${digispark_build_dir}"
82+
$avrdude \
83+
-C"$avrdude_config" \
84+
-v \
85+
-pattiny85 \
86+
-cusbtiny \
87+
-B8 \
88+
-U"flash:w:$attiny85_build_dir/higher_lower.ino.hex:i"
8589

8690
echo
8791
}
@@ -93,7 +97,7 @@ fi
9397

9498
if [ "$1" == 'compile' ]; then
9599
compile_for_arduboy
96-
compile_for_digispark
100+
compile_for_attiny85
97101
exit
98102
fi
99103

@@ -107,8 +111,8 @@ if [ "$1" == 'deploy' ]; then
107111
port="$3"
108112
fi
109113

110-
compile_for_digispark
111-
upload_to_digispark
114+
compile_for_attiny85
115+
upload_with_programmer
112116

113117
exit
114118
fi

0 commit comments

Comments
 (0)