From 514ff44d311ccff78ace88f038a08bb084bc9270 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Sun, 26 Sep 2021 16:45:17 +0300 Subject: [PATCH] refactor: makefile & blink program --- Makefile | 10 ++++++-- firmware.asm | 71 ++++++++++++++++++++++++++-------------------------- firmware.hex | 9 +++---- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 68c3f63..7fba996 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ +MCU = t24 SRCFILE = firmware - -compile: $(SRCFILE).asm +TARGET = usbasp +DEVICE = usb + +build: $(SRCFILE).asm gavrasm $(SRCFILE) + +flash: + avrdude -p $(MCU) -c $(TARGET) -P $(DEVICE) -U flash:w:$(SRCFILE).hex:a clean: rm -f $(SRCFILE).asm~ $(SRCFILE).hex $(SRCFILE).obj $(SRCFILE).lst $(SRCFILE).cof \ No newline at end of file diff --git a/firmware.asm b/firmware.asm index 38c42a8..bad8ae5 100644 --- a/firmware.asm +++ b/firmware.asm @@ -3,16 +3,16 @@ ; Description: Blink an led every one second ; Source code: https://github.com/sergeyyarkov/attiny24a_led-blink-example ; Device: ATtiny24A -; Package: 14-pin-PDIP/SOIC +; Package: 14-pin-PDIP_SOIC ; Assembler: gavrasm v5.0 ; ; Written by Sergey Yarkov 23.09.2021 -.device ATtiny24A +.device ATtiny24A ; Setup device name .list ; Enable listing .macro init_stack_p ; Setup stack pointer - ldi @0, low(@1), + ldi @0, low(@1) out SPL, @0 .endm @@ -20,7 +20,8 @@ .equ LED_PORT = PORTA ; LED Port .equ LED_PIN = PINA0 ; LED Pin -.equ iVal = 65000 +.equ oVal = 20 ; If set to 0, then this value is decremented to 255 +.equ iVal = 10000 ; Value of cycles in inner delay loop .org 0x00 ; Start program at 0x00 .cseg ; Code segment @@ -28,45 +29,43 @@ main: ; Start up program init_stack_p r16, RAMEND rcall init_ports ; Initialize MCU ports - rcall delay_loop_reset + rcall _r_inner_delay_loop ; Initialize delay inner loop value + rcall _r_outer_delay_loop ; Intialize delay outer loop value loop: ; Program loop - cbi LED_PORT, LED_PIN - rcall delay_loop - sbi LED_PORT, LED_PIN - rcall delay_loop - rjmp loop + rcall toggle_led ; Toggle an LED + rcall delay_1s ; Delay for 1 sec + rjmp loop ; Jump to program loop again -init_ports: ; Init MCU ports - ldi r16, (1<