The ultimate bare-metal AVR reference hub. Learn AVR microcontroller programming from scratch — no Arduino libraries, no external dependencies. Pure AVR-GCC with direct register access.
A complete, educational repository for mastering ATtiny85 and ATmega328P (Arduino Nano) at the register level. Every example uses raw AVR-GCC: <avr/io.h>, <avr/interrupt.h>, <util/delay.h> — nothing else.
| Feature | ATtiny85 | ATmega328P (Nano) |
|---|---|---|
| Pins | 8 (6 I/O) | 32 (23 I/O) |
| Flash | 8 KB | 32 KB |
| SRAM | 512 B | 2 KB |
| EEPROM | 512 B | 1 KB |
| Timers | 2 (8-bit) | 3 (2×8-bit, 1×16-bit) |
| ADC | 4 ch, 10-bit | 8 ch, 10-bit |
| UART | USI (software) | 1 hardware USART |
| SPI | USI | 1 hardware SPI |
| I²C (TWI) | USI | 1 hardware TWI |
| PWM | 4 channels | 6 channels |
| Clock | Up to 20 MHz | Up to 20 MHz |
| Voltage | 2.7 – 5.5 V | 1.8 – 5.5 V |
| Price | ~$1 | ~$2–3 |
| Package | DIP-8, SOIC-8 | DIP-28, TQFP-32 |
git clone https://github.com/yourusername/all-about-avr.git
cd all-about-avr
pip install mkdocs mkdocs-material pymdown-extensions
mkdocs serve
# → Open http://127.0.0.1:8000cd examples
# ATtiny85 blink
make MCU=attiny85 TARGET=c/attiny85/gpio/blink_pb0
# ATmega328P blink
make MCU=atmega328p TARGET=c/atmega328p/gpio/blink_pb5
# Flash (adjust -P for your programmer)
make MCU=attiny85 TARGET=c/attiny85/gpio/blink_pb0 flashall-about-avr/
├── docs/ # MkDocs documentation site (Material theme)
│ ├── common/ # Shared AVR basics: toolchain, fuses, debugging
│ ├── attiny85/ # ATtiny85 deep-dives: registers, peripherals
│ └── atmega328p/ # ATmega328P deep-dives: registers, peripherals
├── examples/
│ ├── c/ # Bare-metal C examples per chip
│ │ ├── common/ # Chip-agnostic examples (ifdef)
│ │ ├── attiny85/ # gpio/ timers/ uart/ adc/ sleep/ spi/ pwm/ ...
│ │ └── atmega328p/
│ └── assembly/ # AVR assembly examples
├── tools/ # Fuse calculator (HTML/JS), flash script
├── assets/ # Pinout SVGs, datasheet links
├── benchmarks/ # Performance data (cycles, power)
├── cheat-sheets/ # Quick-reference cards
└── .github/workflows/ # CI: MkDocs deploy + build checks
| Tool | Install Command (Debian/Ubuntu) |
|---|---|
avr-gcc |
sudo apt install gcc-avr |
avr-libc |
sudo apt install avr-libc |
avrdude |
sudo apt install avrdude |
make |
sudo apt install build-essential |
mkdocs |
pip install mkdocs mkdocs-material |
macOS: brew install avr-gcc avrdude
Windows: Install WinAVR or use MSYS2.
- ⚡ GPIO: Digital I/O, pull-ups, port manipulation
- ⏱️ Timers: CTC, PWM (Fast/Phase-Correct), overflow interrupts
- 📡 UART/USART: TX/RX, printf redirect, baud calculation
- 🔌 SPI: Master/Slave, USI on Tiny85
- 🔗 I²C (TWI): Master/Slave, USI-based TWI
- 📈 ADC: Single conversion, free-running, noise reduction
- 💤 Sleep Modes: Idle, Power-Down, wake on interrupt
- 🐕 Watchdog Timer: System reset, wake from sleep
- 🔔 Interrupts: External (INT0/PCINT), timer, ADC complete
- 🔧 Fuses: Clock source, BOD, RSTDISBL, lock bits
See CONTRIBUTING.md for guidelines. TL;DR:
- Write bare-metal C (no Arduino libs)
- Add docs in
docs/+ code inexamples/ - Test on real hardware (or SimulAVR)
- Submit a PR
This project is licensed under the MIT License.
⭐ Star this repo if you love bare-metal AVR!
Built with ❤️ for the embedded community