I corrected the switch orientation and PCB setup, cleared the lid-screw entries, and added recessed USB access; results are recorded in the PCB Placement Report and Project Specification.
The design remains blocked: verification found a real switch/support collision, insufficient button travel, and obstructed diffuser installation—earlier zero-overlap results were incorrect, so I have not started routing.
Unzip, install PlatformIO Core, run pio run. Config uses platform=atmelmegaavr, board=ATtiny402, no Arduino framework, bare-metal avr-libc. Build verified with atmelmegaavr1.10.0 and avr-gcc7.3.0 release build, no compiler/linker warnings printed. Flash366/4096bytes=8.94%; staticRAM5/256bytes=1.95%, excludes stack. No bootloader/offset: flash from0. No fuses written by this starter.
Pins and behavior
PA6 physical2 red, PA7 physical3 green, both active low; PA3 physical7 button active low with external10k pullup. PA0 physical6 untouched UPDI. PA1/PA2 unused with input buffers disabled. Set both LED latches high before output direction enabled; then green only. Each update turns both off before desired LED on, preventing simultaneous on. No retained state. Button held at boot remains green until released stably and pressed again.
Debounce executes bounded work inside periodic RTC PIT ISR: candidate must persist32samples, release arms, stable falling edge toggles once and disarms. Holding never repeats. No blocking delays in button processing. Main clock remains internal OSC20M at reset divide6; documented reset rate2.66MHz or3.3MHz depending16/20MHz oscillator fuse. Build board manifest16MHz does not silently set fuse/clock; firmware uses no CPU delay timing.
RTC selects internal32.768kHz, PIT32cycles nominal0.9765625ms/sample;32samples nominal31.25ms.
Startup RTC waits synchronization, clears pending flag, enables interrupt, then enables PIT. ISR writes1 to clearPI flag.
Timing is approximate: OSCULP32K characterization tolerance over full operating range±30%, so a32sample window about24.04–44.64ms; not a precision timer.
Host verification
Actual src/main.c is included in host test with mocked hardware registers. Run:
Actual output: PASS: boot hold, bounce, edge, hold, release/repress, short release. ASan/UBSan emitted no diagnostics. Mocks do not simulate MCU interrupt latency, electrical behavior or real output register semantics; tests assert logic state and selected output mask. Hardware validation still required.
Programming
Use5V-compatible UPDI programmer (Atmel-ICE UPDI or verified SerialUPDI adapter). J2 pins1=UPDI,2=GND,3=target5V/reference. USB unplugged if programmer powers board; otherwise powered USB and programmer target-power OFF, using rail only for voltage sense. Never connect two supplies; never connect unsupported3.3V-only programmer directly to powered5V target.
Example on host with avrdude8.1 and SerialUPDI adapter:
Replace port and choose adapter-approved baud/programmer ID. Device/programmer support depends host version. Verify flash readback; do not disable UPDI or write oscillator/reset fuses casually. Programming was NOT performed: no hardware attached. Keep all fuse defaults for this starter; BOD configuration remains a future reliability review item.