feat: added simple delay loop

This commit is contained in:
Sergey Yarkov 2021-09-24 23:54:31 +03:00
parent 7fafb8601f
commit 6e07f71337
3 changed files with 19 additions and 8 deletions

View File

@ -1 +1 @@
##led-blink-example ...

View File

@ -1,3 +1,4 @@
;
; Project name: led-blink-example ; Project name: led-blink-example
; Description: Blink an led every one second ; Description: Blink an led every one second
; Source code: https://github.com/sergeyyarkov/attiny24a_led-blink-example ; Source code: https://github.com/sergeyyarkov/attiny24a_led-blink-example
@ -19,20 +20,24 @@
.equ LED_PORT = PORTA ; LED Port .equ LED_PORT = PORTA ; LED Port
.equ LED_PIN = PINA0 ; LED Pin .equ LED_PIN = PINA0 ; LED Pin
.equ delay_cycles = 250 .equ oVal = 70
.equ iVal = 1000
.org 0x00 ; Start program at 0x00 .org 0x00 ; Start program at 0x00
.cseg ; Code segment .cseg ; Code segment
ldi r17, delay_cycles
ldi r18, delay_cycles
ldi r19, delay_cycles
main: ; Start up program main: ; Start up program
init_stack_p r16, RAMEND init_stack_p r16, RAMEND
rcall init_ports ; Initialize MCU ports rcall init_ports ; Initialize MCU ports
ldi r18, oVal
ldi r24, low(iVal)
ldi r25, high(iVal)
loop: ; Program loop loop: ; Program loop
cbi LED_PORT, LED_PIN
rcall delay_loop
sbi LED_PORT, LED_PIN
rcall delay_loop
rjmp loop rjmp loop
init_ports: ; Init MCU ports init_ports: ; Init MCU ports
@ -42,3 +47,8 @@ init_ports: ; Init MCU ports
out LED_DIR, r16 out LED_DIR, r16
out LED_PORT, r17 out LED_PORT, r17
ret ret
delay_loop:
sbiw r24, 1
brne delay_loop
ret

View File

@ -1,4 +1,5 @@
:020000020000FC :020000020000FC
:100000001AEF2AEF3AEF0FED0DBF01D0FFCF01E05D :100000000FED0DBF08D026E488EE93E0D89809D014
:0A00100010E000000ABB1BBB0895BE :10001000D89A07D0FBCF01E010E000000ABB1BBB61
:0800200008950197F1F708951E
:00000001FF :00000001FF