blink.c |
/* * blink * Juan Galaz * seta43.duckdns.org * seta43.blogspot.com * 2021 */ #define F_CPU 16000000L #include <avr/io.h> #include <util/delay.h> int main (void) { DDRB = 0xff; PORTB = 0x03; while(1) { PORTB = 0x01; _delay_ms(500); PORTB = 0x00; _delay_ms(500); } return 0; } |
Makefile |
MCU=atmega328 #F_CPU=16000000 CC=avr-gcc OBJCOPY=avr-objcopy #CFLAGS=-std=c99 -Wall -g -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -I. CFLAGS=-std=c99 -Wall -g -Os -mmcu=${MCU} -I. TARGET=blink SRCS=blink.c all: ${CC} ${CFLAGS} -o ${TARGET}.bin ${SRCS} ${OBJCOPY} -j .text -j .data -O ihex ${TARGET}.bin ${TARGET}.hex flash: avrdude -p ${MCU} -c usbasp -U flash:w:${TARGET}.hex:i -F -P usb clean: rm -f *.bin *.hex |