hola.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 = 0x03; _delay_ms(400); PORTB = 0x00; _delay_ms(500); } return 0; } |
Makefile |
MCU=atmega328 F_CPU=16000000CC=avr-gcc OBJCOPY=avr-objcopyCFLAGS=-std=c99 -Wall -g -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -I. TARGET=holaSRCS=hola.c all: ${OBJCOPY} -j .text -j .data -O ihex ${TARGET}.bin ${TARGET}.hex flash: avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:${TARGET}.hex:i flash2: avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -U flash:w:${TARGET}.hex:i -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m clean: rm -f *.bin *.hex |
Consola |
make flash avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -Uflash:w:hola.hex:i ..... .... Writing | ################################################## | 100% 0.31s avrdude: 182 bytes of flash written avrdude: verifying flash memory against hola.hex: avrdude: load data flash data from input file hola.hex: avrdude: input file hola.hex contains 182 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.20s avrdude: verifying ... avrdude: 182 bytes of flash verified avrdude: safemode: lfuse reads as FF avrdude: safemode: hfuse reads as D9 avrdude: safemode: efuse reads as FF avrdude: safemode: Fuses OK (E:FF, H:D9, L:FF) avrdude done. Thank you. |