...and others MCUs with some changes probably.
This is a collection of sample programs I created to learn how to use I/O, timers and interrupts etc. on AVR microcontrollers.
Alternatingly flashes two LEDs connected to pins 14 & 15 on the ATMega64A.
────┐
├─ Pin 14 (PB4) ─ ( 1kΩ ) ─ ( LED ) ──┐
MCU │ │
├─ Pin 15 (PB5) ─ ( 1kΩ ) ─ ( LED ) ──┤
────┘ GND
Writes a 16 bit counter to a LDP-M3604RI-UR 5 digit 7-segment LED numeric display uisng USART1 on the MCU, increments the counter, then reads from USART1 unitl the display responds, and loops as fast as possible forever.
────┐
├─ Pin 27 (PD2/RXD1) ────┐
MCU │ │
├─ Pin 28 (PD3/TXD1) ──┐ │ ┌─────────────────┐
────┘ │ └──── TX1 ─┤ │
└────── RX1 ─┤ LDP-M3604RI-UR │
+3.3V ────────────────────────── +3.3V ─┤ │
GND ──────────────────────────── GND ─┤ │
└─────────────────┘
On a debian based system install the requirements
sudo apt install gcc-avr binutils-avr avr-libc avrdude -yor build them yourself using these instructions.
Add your avr/include/ location to the include path in your editor.
# Compile
avr-gcc -mmcu=atmega64a -Os -DF_CPU=8000000UL -c blink.c -o blink.o
# Link
avr-gcc -mmcu=atmega64a blink.o -o blink.elf
# Create hex file
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature \
blink.elf blink.hex
# Flash
avrdude -c usbasp -p m64 -B 16 -U flash:w:blink.hex:iA makefile is provided for building, setting fuses and uploading.
make Compile and convert all examples
make upload-<name> Upload program to MCU
make fuses Program ATmega64A fuses
make clean Remove only build folder
make clean-all Remove build and hex folders (I am box)
|/
┌───┬───┐
│ │ │
├───┼───┤
│ │ │
└───┴───┘