refactored

This commit is contained in:
Sergey Yarkov 2023-01-28 19:46:06 +03:00
parent 1f057d5d55
commit 9a5cd93e9f
No known key found for this signature in database
GPG Key ID: E91CE1FABC619B6F
2 changed files with 26 additions and 47 deletions

View File

@ -14,6 +14,8 @@
.INCLUDE "tn2313Adef.inc"
.LIST
.DEF TEMP_A = r16 ; Temp register A
.DEF TEMP_B = r17 ; Temp register B
.DEF DATA = r20 ; DATA to transmit
;========================================;
@ -36,39 +38,30 @@
;========================================;
rjmp RESET_vect ; Program start at RESET vector
;reti ; External Interrupt Request 0 / inactive
;reti ; External Interrupt Request 1 / inactive
;reti ; Timer/Counter1 Capture Event / inactive
;reti ; Timer/Counter1 Compare Match A / inactive
;reti ; Timer/Counter1 Overflow / inactive
;reti ; Timer/Counter0 Overflow / inactive
;reti ; USART0, Rx Complete / inactive
;reti ; USART0 Data Register Empty / inactive
;reti ; USART0, Tx Complete / inactive
;reti ; Analog Comparator / inactive
;reti ; Pin Change Interrupt Request 0/ inactive
;reti ; Timer/Counter1 Compare Match B / inactive
;reti ; Timer/Counter0 Compare Match A / inactive
;reti ; Timer/Counter0 Compare Match B / inactive
;reti ; USI Start Condition/ inactive
;reti ; USI Overflow / inactive
;reti ; EEPROM Ready/ inactive
;reti ; Watchdog Timer Overflow / inactive
;reti ; Pin Change Interrupt Request 1 / inactive
;reti ; Pin Change Interrupt Request 2 / inactive
RESET_vect:
;========================================;
; INITIALIZE STACK POINTER ;
;========================================;
ldi r16, low(RAMEND)
out SPL, r16
ldi TEMP_A, low(RAMEND)
out SPL, TEMP_A
MCU_INIT:
rcall INIT_PORTS
ldi DATA, 0b00000001
rjmp LOOP
;========================================;
; MAIN PROGRAM LOOP ;
;========================================;
LOOP:
rcall TRANSMIT_595
rcall DELAY
rol DATA
rjmp LOOP
INIT_PORTS:
ldi r16, (1<<CLOCK_PIN) | (1<<LATCH_PIN) | (1<<DATA_PIN)
out DDRB, r16
@ -77,9 +70,8 @@ ret
;========================================;
; SEND BYTE TO 74HC595 ;
;========================================;
TRANSMIT_595:
push r19
push r21
in r21, SREG
mov r19, DATA
ldi r16, 8
@ -103,31 +95,19 @@ TRANSMIT_595:
sbi PORTB, LATCH_PIN
cbi PORTB, LATCH_PIN
out SREG, r21
pop r21
pop r19
ret
;========================================;
; MAIN PROGRAM LOOP ;
;========================================;
LOOP:
rcall TRANSMIT_595
rcall DELAY
rol DATA
rjmp LOOP
DELAY:
ldi r16, 70
ldi TEMP_A, 70
_DELAY_1:
ldi r17, 255
ldi TEMP_B, 255
_DELAY_2:
dec r17
dec TEMP_B
nop
nop
nop
brne _DELAY_2
dec r16
dec TEMP_A
brne _DELAY_1
ret

View File

@ -1,8 +1,7 @@
:020000020000FC
:1000000000C00FED0DBF02D041E018C007E007BBF4
:1000100008953F935F935FB7342F08E0330F18F4D0
:1000200000F0C19A01C0C198C09AC0980A95B1F772
:10003000C29AC2985FBF5F913F910895EADF02D0F4
:10004000441FFCCF06E41FEF1A95000000000000DB
:08005000D9F70A95C1F70895E4
:1000000000C00FED0DBF06D041E000C006D016D0F5
:10001000441FFCCF07E007BB08955FB7342F08E00B
:10002000330F18F400F0C19A01C0C198C09AC0986B
:100030000A95B1F7C29AC2985FBF089506E41FEF10
:100040001A95000000000000D9F70A95C1F708953D
:00000001FF