shift register

This commit is contained in:
Sergey Yarkov 2023-01-28 03:36:06 +03:00
parent 0f4110bfd4
commit 108f5dbdba
No known key found for this signature in database
GPG Key ID: E91CE1FABC619B6F
6 changed files with 514 additions and 288 deletions

View File

@ -15,13 +15,16 @@
.LIST
.DEF tmp_r_a = r16
.DEF COUNTER = r20
;========================================;
; LABELS ;
;========================================;
.EQU LED_POWER_PORT = PD6
.EQU LED_POWER_PORT = PD6
.EQU CLOCK_PIN = PB0 ; ST_CP on 74HC595
.EQU DATA_PIN = PB1 ; DS on 74HC595
.EQU LATCH_PIN = PB2 ; SH_CP on 74HC595
;========================================;
; CODE SEGMENT ;
@ -35,41 +38,95 @@
;========================================;
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
;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:
;
; INIT STACK POINTER
ldi tmp_r_a, low(RAMEND)
out SPL, tmp_r_a
;========================================;
; INITIALIZE STACK POINTER ;
;========================================;
ldi tmp_r_a, low(RAMEND)
out SPL, tmp_r_a
MCU_INIT:
rcall INIT_PORTS
rjmp LOOP
;=======================================================
; POWER LED <------------> PD6 ;
; - This LED is used to indicate that device ;
; is working correctly ;
; ;
;=======================================================
rcall INIT_PORTS
;========================================;
; USI IS USED TO COMMUNICATE ;
; WITH SHIFT REGISTER (74HC595N) ;
;========================================;
rcall INIT_USI
ldi COUNTER, 0
rjmp LOOP
INIT_PORTS:
ldi r16, (1<<LED_POWER_PORT)
out DDRD, r16
out PORTD, r16
ldi r16, (1<<LED_POWER_PORT)
out DDRD, r16
ldi r16, (1<<CLOCK_PIN) | (1<<LATCH_PIN) | (1<<DATA_PIN)
out DDRB, r16
ret
INIT_USI:
ret
;========================================;
; SEND BYTE TO 74HC595 ;
;========================================;
TRANSMIT_595:
push r19
mov r19, COUNTER
ldi r16, 8
_TRANSMIT_595_LOOP:
lsl r19
brcc _TRANSMIT_595_SEND_LOW
brcs _TRANSMIT_595_SEND_HIGH
_TRANSMIT_595_SEND_HIGH:
sbi PORTB, DATA_PIN
rjmp _TRANSMIT_595_COMMIT
_TRANSMIT_595_SEND_LOW:
cbi PORTB, DATA_PIN
_TRANSMIT_595_COMMIT:
sbi PORTB, CLOCK_PIN
cbi PORTB, CLOCK_PIN
sbi PORTB, LATCH_PIN
cbi PORTB, LATCH_PIN
dec r16
brne _TRANSMIT_595_LOOP
pop r19
ret
SUBPROGRAM_LED_SHIFTING:
rcall TRANSMIT_595
inc COUNTER
ret
;========================================;
@ -77,37 +134,44 @@ ret
;========================================;
LOOP:
ldi r16, (1<<LED_POWER_PORT)
out PORTD, r16
rcall DELAY
rcall DELAY
ldi r16, (0<<LED_POWER_PORT)
out PORTD, r16
rcall DELAY
rcall DELAY
rjmp LOOP
rcall TOGGLE_POWER_LED
rcall SUBPROGRAM_LED_SHIFTING
rcall DELAY
rjmp LOOP
DELAY:
ldi r16, 255 ; 1 clock cycle
_DEL_1:
ldi r17, 255 ; 1 clock cycle
_DEL_2:
dec r17 ; 1 clock cycle
nop ; 1 clock cycle
brne _DEL_2 ; 2 clock cycle when jumping / 1 when continue
push r16
push r17
cli
ldi r16, 20 ; 1
_DELAY_1:
ldi r17, 255
_DELAY_2:
dec r17
nop
nop
nop
brne _DELAY_2
dec r16 ; 1 clock cycle
brne _DEL_1 ; 2 clock cycle when jumping / 1 when continue
dec r16
brne _DELAY_1
sei
pop r17
pop r16
ret
TOGGLE_POWER_LED:
ldi r16, (1<<LED_POWER_PORT)
in r17, PORTD
eor r17, r16
out PORTD, r17
ret
INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"
;========================================;
; EEPROM SEGMENT ;
;========================================;
.ESEG
INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"

5
firmware.eep Normal file
View File

@ -0,0 +1,5 @@
:1000000041565220544845524D4F535441542E208E
:100010005752495454454E20425920534552474562
:1000200059205941524B4F562032322E30312E3208
:0300300030323338
:00000001FF

View File

@ -1,11 +1,10 @@
:020000020000FC
:1000000014C0189518951895189518951895189561
:100010001895189518951895189518951895189578
:10002000189518951895189518950FED0DBF01D0D6
:1000300004C000E401BB02BB089500E402BB06D08B
:1000400005D000E002BB02D001D0F7CF0FEF1FEFC9
:100050001A950000E9F70A95D1F708954156522004
:10006000546865726D6F737461742E205772697471
:1000700074656E20627920536572676579205961D5
:10008000726B6F762032322E30312E3230323300A6
:1000000000C00FED0DBF03D007D040E01AC000E4E0
:1000100001BB07E007BB089508953F93342F08E024
:10002000330F18F400F0C19A01C0C198C09AC0986B
:10003000C29AC2980A95A1F73F910895EEDF4395C1
:10004000089513D0FBDF01D0FCCF0F931F93F894DA
:1000500004E11FEF1A95000000000000D9F70A958F
:10006000C1F778941F910F91089500E412B31027FF
:0400700012BB089522
:00000001FF

View File

@ -1,5 +1,5 @@
AVRASM ver. 2.2.7 firmware.asm Tue Jan 24 01:18:37 2023
AVRASM ver. 2.2.7 firmware.asm Sat Jan 28 03:33:17 2023
firmware.asm(14): Including file 'tn2313Adef.inc'
firmware.asm(14): Including file 'tn2313Adef.inc'
@ -719,13 +719,16 @@ firmware.asm(14): Including file 'tn2313Adef.inc'
.LIST
.DEF tmp_r_a = r16
.DEF COUNTER = r20
;========================================;
; LABELS ;
;========================================;
.EQU LED_POWER_PORT = PD6
.EQU LED_POWER_PORT = PD6
.EQU CLOCK_PIN = PB0 ; ST_CP on 74HC595
.EQU DATA_PIN = PB1 ; DS on 74HC595
.EQU LATCH_PIN = PB2 ; SH_CP on 74HC595
;========================================;
; CODE SEGMENT ;
@ -738,108 +741,193 @@ firmware.asm(14): Including file 'tn2313Adef.inc'
; VECTORS ;
;========================================;
000000 c014 rjmp RESET_vect ; Program start at RESET vector
000001 9518 reti ; External Interrupt Request 0 / inactive
000002 9518 reti ; External Interrupt Request 1 / inactive
000003 9518 reti ; Timer/Counter1 Capture Event / inactive
000004 9518 reti ; Timer/Counter1 Compare Match A / inactive
000005 9518 reti ; Timer/Counter1 Overflow / inactive
000006 9518 reti ; Timer/Counter0 Overflow / inactive
000007 9518 reti ; USART0, Rx Complete / inactive
000008 9518 reti ; USART0 Data Register Empty / inactive
000009 9518 reti ; USART0, Tx Complete / inactive
00000a 9518 reti ; Analog Comparator / inactive
00000b 9518 reti ; Pin Change Interrupt Request 0/ inactive
00000c 9518 reti ; Timer/Counter1 Compare Match B / inactive
00000d 9518 reti ; Timer/Counter0 Compare Match A / inactive
00000e 9518 reti ; Timer/Counter0 Compare Match B / inactive
00000f 9518 reti ; USI Start Condition/ inactive
000010 9518 reti ; USI Overflow / inactive
000011 9518 reti ; EEPROM Ready/ inactive
000012 9518 reti ; Watchdog Timer Overflow / inactive
000013 9518 reti ; Pin Change Interrupt Request 1 / inactive
000014 9518 reti ; Pin Change Interrupt Request 2 / inactive
000000 c000 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:
;
; INIT STACK POINTER
000015 ed0f ldi tmp_r_a, low(RAMEND)
000016 bf0d out SPL, tmp_r_a
;========================================;
; INITIALIZE STACK POINTER ;
;========================================;
000001 ed0f ldi tmp_r_a, low(RAMEND)
000002 bf0d out SPL, tmp_r_a
MCU_INIT:
000017 d001 rcall INIT_PORTS
000018 c004 rjmp LOOP
;=======================================================
; POWER LED <------------> PD6 ;
; - This LED is used to indicate that device ;
; is working correctly ;
; ;
;=======================================================
000003 d003 rcall INIT_PORTS
;========================================;
; USI IS USED TO COMMUNICATE ;
; WITH SHIFT REGISTER (74HC595N) ;
;========================================;
000004 d007 rcall INIT_USI
000005 e040 ldi COUNTER, 0
000006 c01a rjmp LOOP
INIT_PORTS:
000019 e400 ldi r16, (1<<LED_POWER_PORT)
00001a bb01 out DDRD, r16
00001b bb02 out PORTD, r16
00001c 9508 ret
000007 e400 ldi r16, (1<<LED_POWER_PORT)
000008 bb01 out DDRD, r16
000009 e007 ldi r16, (1<<CLOCK_PIN) | (1<<LATCH_PIN) | (1<<DATA_PIN)
00000a bb07 out DDRB, r16
00000b 9508 ret
INIT_USI:
00000c 9508 ret
;========================================;
; SEND BYTE TO 74HC595 ;
;========================================;
TRANSMIT_595:
00000d 933f push r19
00000e 2f34 mov r19, COUNTER
00000f e008 ldi r16, 8
_TRANSMIT_595_LOOP:
000010 0f33 lsl r19
000011 f418 brcc _TRANSMIT_595_SEND_LOW
000012 f000 brcs _TRANSMIT_595_SEND_HIGH
_TRANSMIT_595_SEND_HIGH:
000013 9ac1 sbi PORTB, DATA_PIN
000014 c001 rjmp _TRANSMIT_595_COMMIT
_TRANSMIT_595_SEND_LOW:
000015 98c1 cbi PORTB, DATA_PIN
_TRANSMIT_595_COMMIT:
000016 9ac0 sbi PORTB, CLOCK_PIN
000017 98c0 cbi PORTB, CLOCK_PIN
000018 9ac2 sbi PORTB, LATCH_PIN
000019 98c2 cbi PORTB, LATCH_PIN
00001a 950a dec r16
00001b f7a1 brne _TRANSMIT_595_LOOP
00001c 913f pop r19
00001d 9508 ret
SUBPROGRAM_LED_SHIFTING:
00001e dfee rcall TRANSMIT_595
00001f 9543 inc COUNTER
000020 9508 ret
;========================================;
; MAIN PROGRAM LOOP ;
;========================================;
LOOP:
00001d e400 ldi r16, (1<<LED_POWER_PORT)
00001e bb02 out PORTD, r16
00001f d006 rcall DELAY
000020 d005 rcall DELAY
000021 e000 ldi r16, (0<<LED_POWER_PORT)
000022 bb02 out PORTD, r16
000023 d002 rcall DELAY
000024 d001 rcall DELAY
000025 cff7 rjmp LOOP
000021 d013 rcall TOGGLE_POWER_LED
000022 dffb rcall SUBPROGRAM_LED_SHIFTING
000023 d001 rcall DELAY
000024 cffc rjmp LOOP
DELAY:
000026 ef0f ldi r16, 255 ; 1 clock cycle
_DEL_1:
000027 ef1f ldi r17, 255 ; 1 clock cycle
_DEL_2:
000028 951a dec r17 ; 1 clock cycle
000029 0000 nop ; 1 clock cycle
00002a f7e9 brne _DEL_2 ; 2 clock cycle when jumping / 1 when continue
000025 930f push r16
000026 931f push r17
000027 94f8 cli
000028 e104 ldi r16, 20 ; 1
_DELAY_1:
000029 ef1f ldi r17, 255
_DELAY_2:
00002a 951a dec r17
00002b 0000 nop
00002c 0000 nop
00002d 0000 nop
00002e f7d9 brne _DELAY_2
00002b 950a dec r16 ; 1 clock cycle
00002c f7d1 brne _DEL_1 ; 2 clock cycle when jumping / 1 when continue
00002d 9508 ret
00002f 950a dec r16
000030 f7c1 brne _DELAY_1
000031 9478 sei
000032 911f pop r17
000033 910f pop r16
000034 9508 ret
TOGGLE_POWER_LED:
000035 e400 ldi r16, (1<<LED_POWER_PORT)
000036 b312 in r17, PORTD
000037 2710 eor r17, r16
000038 bb12 out PORTD, r17
000039 9508 ret
00002e 5641
00002f 2052
000030 6854
000031 7265
000032 6f6d
000033 7473
000034 7461
000035 202e
000036 7257
000037 7469
000038 6574
000039 206e
00003a 7962
00003b 5320
00003c 7265
00003d 6567
00003e 2079
00003f 6159
000040 6b72
000041 766f
000042 3220
000043 2e32
000044 3130
000045 322e
000046 3230
firmware.asm(107): warning: .cseg .db misalignment - padding zero byte
000047 0033 INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"
;========================================;
; EEPROM SEGMENT ;
;========================================;
.ESEG
000000 41
000001 56
000002 52
000003 20
000004 54
000005 68
000006 65
000007 72
000008 6d
000009 6f
00000a 73
00000b 74
00000c 61
00000d 74
00000e 2e
00000f 20
000010 57
000011 72
000012 69
000013 74
000014 74
000015 65
000016 6e
000017 20
000018 62
000019 79
00001a 20
00001b 53
00001c 65
00001d 72
00001e 67
00001f 65
000020 79
000021 20
000022 59
000023 61
000024 72
000025 6b
000026 6f
000027 76
000028 20
000029 32
00002a 32
00002b 2e
00002c 30
00002d 31
00002e 2e
00002f 32
000030 30
000031 32
RESOURCE USE INFORMATION
@ -859,37 +947,37 @@ counted separately from r26..r31 here.
"ATtiny2313A" register use summary:
x : 0 y : 0 z : 0 r0 : 0 r1 : 0 r2 : 0 r3 : 0 r4 : 0
r5 : 0 r6 : 0 r7 : 0 r8 : 0 r9 : 0 r10: 0 r11: 0 r12: 0
r13: 0 r14: 0 r15: 0 r16: 11 r17: 2 r18: 0 r19: 0 r20: 0
r13: 0 r14: 0 r15: 0 r16: 14 r17: 7 r18: 0 r19: 4 r20: 3
r21: 0 r22: 0 r23: 0 r24: 0 r25: 0 r26: 0 r27: 0 r28: 0
r29: 0 r30: 0 r31: 0
Registers used: 2 out of 35 (5.7%)
Registers used: 4 out of 35 (11.4%)
"ATtiny2313A" instruction use summary:
.lds : 0 .sts : 0 adc : 0 add : 0 adiw : 0 and : 0
andi : 0 asr : 0 bclr : 0 bld : 0 brbc : 0 brbs : 0
brcc : 0 brcs : 0 break : 0 breq : 0 brge : 0 brhc : 0
brcc : 1 brcs : 1 break : 0 breq : 0 brge : 0 brhc : 0
brhs : 0 brid : 0 brie : 0 brlo : 0 brlt : 0 brmi : 0
brne : 2 brpl : 0 brsh : 0 brtc : 0 brts : 0 brvc : 0
brvs : 0 bset : 0 bst : 0 cbi : 0 cbr : 0 clc : 0
clh : 0 cli : 0 cln : 0 clr : 0 cls : 0 clt : 0
brne : 3 brpl : 0 brsh : 0 brtc : 0 brts : 0 brvc : 0
brvs : 0 bset : 0 bst : 0 cbi : 3 cbr : 0 clc : 0
clh : 0 cli : 1 cln : 0 clr : 0 cls : 0 clt : 0
clv : 0 clz : 0 com : 0 cp : 0 cpc : 0 cpi : 0
cpse : 0 dec : 2 eor : 0 icall : 0 ijmp : 0 in : 0
inc : 0 ld : 0 ldd : 0 ldi : 6 lds : 0 lpm : 0
lsl : 0 lsr : 0 mov : 0 movw : 0 neg : 0 nop : 1
or : 0 ori : 0 out : 5 pop : 0 push : 0 rcall : 5
ret : 2 reti : 20 rjmp : 3 rol : 0 ror : 0 sbc : 0
sbci : 0 sbi : 0 sbic : 0 sbis : 0 sbiw : 0 sbr : 0
sbrc : 0 sbrs : 0 sec : 0 seh : 0 sei : 0 sen : 0
cpse : 0 dec : 3 eor : 1 icall : 0 ijmp : 0 in : 1
inc : 1 ld : 0 ldd : 0 ldi : 8 lds : 0 lpm : 0
lsl : 1 lsr : 0 mov : 1 movw : 0 neg : 0 nop : 3
or : 0 ori : 0 out : 4 pop : 3 push : 3 rcall : 6
ret : 6 reti : 0 rjmp : 4 rol : 0 ror : 0 sbc : 0
sbci : 0 sbi : 3 sbic : 0 sbis : 0 sbiw : 0 sbr : 0
sbrc : 0 sbrs : 0 sec : 0 seh : 0 sei : 1 sen : 0
ser : 0 ses : 0 set : 0 sev : 0 sez : 0 sleep : 0
spm : 0 st : 0 std : 0 sts : 0 sub : 0 subi : 0
swap : 0 tst : 0 wdr : 0
Instructions used: 9 out of 105 (8.6%)
Instructions used: 21 out of 105 (20.0%)
"ATtiny2313A" memory use summary [bytes]:
Segment Begin End Code Data Used Size Use%
---------------------------------------------------------------
[.cseg] 0x000000 0x000090 92 52 144 2048 7.0%
[.cseg] 0x000000 0x000074 116 0 116 2048 5.7%
[.dseg] 0x000060 0x000060 0 0 0 128 0.0%
[.eseg] 0x000000 0x000000 0 0 0 128 0.0%
[.eseg] 0x000000 0x000033 0 51 51 128 39.8%
Assembly complete, 0 errors, 1 warnings
Assembly complete, 0 errors, 0 warnings

View File

@ -5,7 +5,7 @@ Path: /home/sergeyyarkov/Documents/Applications/attiny2313a_thermostat/
Source file: firmware.asm
Hex file: firmware.hex
Eeprom file: firmware.eep
Compiled: 24.01.2023, 01:15:04
Compiled: 28.01.2023, 02:47:03
Pass: 2
1: ;
@ -28,136 +28,207 @@ Pass: 2
15: .LIST
16:
17: .DEF tmp_r_a = r16
18:
19: ;========================================;
20: ; LABELS ;
21: ;========================================;
22:
23: .EQU LED_POWER_PORT = PD6
24:
25:
26: ;========================================;
27: ; CODE SEGMENT ;
28: ;========================================;
29:
30: .CSEG
31: .ORG 0x00
18: .DEF COUNTER = r20
19:
20: ;========================================;
21: ; LABELS ;
22: ;========================================;
23:
24: .EQU LED_POWER_PORT = PD6
25: .EQU CLOCK_PIN = PB0 ; ST_CP on 74HC595
26: .EQU LATCH_PIN = PB1 ; SH_CP on 74HC595
27: .EQU DATA_PIN = PB2 ; DS on 74HC595
28:
29: ;========================================;
30: ; CODE SEGMENT ;
31: ;========================================;
32:
33: ;========================================;
34: ; VECTORS ;
35: ;========================================;
36:
37: 000000 C014 rjmp RESET_vect ; Program start at RESET vector
38: 000001 9518 reti ; External Interrupt Request 0 / inactive
39: 000002 9518 reti ; External Interrupt Request 1 / inactive
40: 000003 9518 reti ; Timer/Counter1 Capture Event / inactive
41: 000004 9518 reti ; Timer/Counter1 Compare Match A / inactive
42: 000005 9518 reti ; Timer/Counter1 Overflow / inactive
43: 000006 9518 reti ; Timer/Counter0 Overflow / inactive
44: 000007 9518 reti ; USART0, Rx Complete / inactive
45: 000008 9518 reti ; USART0 Data Register Empty / inactive
46: 000009 9518 reti ; USART0, Tx Complete / inactive
47: 00000A 9518 reti ; Analog Comparator / inactive
48: 00000B 9518 reti ; Pin Change Interrupt Request 0/ inactive
49: 00000C 9518 reti ; Timer/Counter1 Compare Match B / inactive
50: 00000D 9518 reti ; Timer/Counter0 Compare Match A / inactive
51: 00000E 9518 reti ; Timer/Counter0 Compare Match B / inactive
52: 00000F 9518 reti ; USI Start Condition/ inactive
53: 000010 9518 reti ; USI Overflow / inactive
54: 000011 9518 reti ; EEPROM Ready/ inactive
55: 000012 9518 reti ; Watchdog Timer Overflow / inactive
56: 000013 9518 reti ; Pin Change Interrupt Request 1 / inactive
57: 000014 9518 reti ; Pin Change Interrupt Request 2 / inactive
58:
59: RESET_vect:
60: ;
61: ; INIT STACK POINTER
62: 000015 ED0F ldi tmp_r_a, low(RAMEND)
63: 000016 BF0D out SPL, tmp_r_a
64:
65: MCU_INIT:
66: 000017 D001 rcall INIT_PORTS
67: 000018 C004 rjmp LOOP
33: .CSEG
34: .ORG 0x00
35:
36: ;========================================;
37: ; VECTORS ;
38: ;========================================;
39:
40: 000000 C000 rjmp RESET_vect ; Program start at RESET vector
41: ;reti ; External Interrupt Request 0 / inactive
42: ;reti ; External Interrupt Request 1 / inactive
43: ;reti ; Timer/Counter1 Capture Event / inactive
44: ;reti ; Timer/Counter1 Compare Match A / inactive
45: ;reti ; Timer/Counter1 Overflow / inactive
46: ;reti ; Timer/Counter0 Overflow / inactive
47: ;reti ; USART0, Rx Complete / inactive
48: ;reti ; USART0 Data Register Empty / inactive
49: ;reti ; USART0, Tx Complete / inactive
50: ;reti ; Analog Comparator / inactive
51: ;reti ; Pin Change Interrupt Request 0/ inactive
52: ;reti ; Timer/Counter1 Compare Match B / inactive
53: ;reti ; Timer/Counter0 Compare Match A / inactive
54: ;reti ; Timer/Counter0 Compare Match B / inactive
55: ;reti ; USI Start Condition/ inactive
56: ;reti ; USI Overflow / inactive
57: ;reti ; EEPROM Ready/ inactive
58: ;reti ; Watchdog Timer Overflow / inactive
59: ;reti ; Pin Change Interrupt Request 1 / inactive
60: ;reti ; Pin Change Interrupt Request 2 / inactive
61:
62: RESET_vect:
63: ;========================================;
64: ; INITIALIZE STACK POINTER ;
65: ;========================================;
66: 000001 ED0F ldi tmp_r_a, low(RAMEND)
67: 000002 BF0D out SPL, tmp_r_a
68:
69: INIT_PORTS:
70: 000019 E400 ldi r16, (1<<LED_POWER_PORT)
71: 00001A BB01 out DDRD, r16
72: 00001B BB02 out PORTD, r16
73: 00001C 9508 ret
74:
75: ;========================================;
76: ; MAIN PROGRAM LOOP ;
77: ;========================================;
78:
79: LOOP:
80: 00001D E400 ldi r16, (1<<LED_POWER_PORT)
81: 00001E BB02 out PORTD, r16
82:
83: 00001F D006 rcall DELAY
84: 000020 D005 rcall DELAY
69: MCU_INIT:
70: ;=======================================================
71: ; POWER LED <------------> PD6 ;
72: ; - This LED is used to indicate that device ;
73: ; is working correctly ;
74: ; ;
75: ;=======================================================
76: 000003 D002 rcall INIT_PORTS
77:
78: ;========================================;
79: ; USI IS USED TO COMMUNICATE ;
80: ; WITH SHIFT REGISTER (74HC595N) ;
81: ;========================================;
82: 000004 D006 rcall INIT_USI
83:
84: 000005 C01D rjmp LOOP
85:
86: 000021 E000 ldi r16, (0<<LED_POWER_PORT)
87: 000022 BB02 out PORTD, r16
88:
89: 000023 D002 rcall DELAY
90: 000024 D001 rcall DELAY
91:
92: 000025 CFF7 rjmp LOOP
93:
94: DELAY:
95: 000026 E302 ldi r16, 50 ; 1 clock cycle
96: _DEL_1:
97: 000027 EF1F ldi r17, 255 ; 1 clock cycle
98: _DEL_2:
99: 000028 951A dec r17 ; 1 clock cycle
100: 000029 0000 nop ; 1 clock cycle
101: 00002A F7E9 brne _DEL_2 ; 2 clock cycle when jumping / 1 when continue
102:
103: 00002B 950A dec r16 ; 1 clock cycle
104: 00002C F7D1 brne _DEL_1 ; 2 clock cycle when jumping / 1 when continue
105: 00002D 9508 ret
106:
107: INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"
-> Warning 004: Number of bytes on line is odd, added 00 to fit program memory!
File: /home/sergeyyarkov/Documents/Applications/attiny2313a_thermostat/firmware.asm, Line: 107
Source line: INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"
00002E 5641 2052 4854 5245
000032 4F4D 5453 5441 202E
000036 5257 5449 4554 204E
00003A 5942 5320 5245 4547
00003E 2059 4159 4B52 564F
000042 3220 2E32 3130 322E
000046 3230 0033
108:
109: ;========================================;
110: ; EEPROM SEGMENT ;
111: ;========================================;
112:
113: .ESEG
86: INIT_PORTS:
87: 000006 E400 ldi r16, (1<<LED_POWER_PORT)
88: 000007 BB01 out DDRD, r16
89: 000008 E007 ldi r16, (1<<CLOCK_PIN) | (1<<LATCH_PIN) | (1<<DATA_PIN)
90: 000009 BB07 out DDRB, r16
91: 00000A 9508 ret
92:
93: INIT_USI:
94:
95: 00000B 9508 ret
96:
97: CLOCK_595:
98: 00000C 930F push r16
99: 00000D E001 ldi r16, (1<<CLOCK_PIN)
100: 00000E B318 in r17, PORTB
101: 00000F 2710 eor r17, r16
102: 000010 BB18 out PORTB, r17
103: 000011 910F pop r16
104: 000012 9508 ret
105:
106: TRANSMIT_595:
107: 000013 933F push r19
108: 000014 E23A ldi r19, 0b00101010 ; Data to transmit
109: 000015 E008 ldi r16, 8
110: _TRANSMIT_595_LOOP:
111: 000016 0F33 lsl r19
112: 000017 F410 brcc _TRANSMIT_595_SEND_LOW
113: 000018 F000 brcs _TRANSMIT_595_SEND_HIGH
114:
115: _TRANSMIT_595_SEND_HIGH:
116: 000019 C000 rjmp _TRANSMIT_595_PROCEED
117:
118:
119: _TRANSMIT_595_SEND_LOW:
120:
121: _TRANSMIT_595_PROCEED:
122: 00001A DFF1 rcall CLOCK_595
123: 00001B DFF0 rcall CLOCK_595
124: 00001C 950A dec r16
125: 00001D F7C1 brne _TRANSMIT_595_LOOP
126: 00001E 913F pop r19
127: 00001F 9508 ret
128:
129: SUBPROGRAM_LED_SHIFTING:
130: 000020 9543 inc COUNTER
131: 000021 DFF1 rcall TRANSMIT_595
132: 000022 9508 ret
133:
134: ;========================================;
135: ; MAIN PROGRAM LOOP ;
136: ;========================================;
137:
138: LOOP:
139: 000023 D00F rcall TOGGLE_POWER_LED
140: 000024 DFFB rcall SUBPROGRAM_LED_SHIFTING
141: 000025 D001 rcall DELAY
142: 000026 CFFC rjmp LOOP
143:
144: DELAY:
145: 000027 94F8 cli
146: 000028 E00A ldi r16, 10 ; 1
147: _DELAY_1:
148: 000029 EF1F ldi r17, 255 ; 1
149: _DELAY_2:
150: 00002A 951A dec r17 ; 1
151: 00002B 0000 nop ; 1
152: 00002C 0000 nop ; 1
153: 00002D 0000 nop ; 1
154: 00002E F7D9 brne _DELAY_2 ; 2/1
155:
156: 00002F 950A dec r16
157: 000030 F7C1 brne _DELAY_1 ; 2/1
158: 000031 9478 sei
159: 000032 9508 ret ; 4
160:
161: TOGGLE_POWER_LED:
162: 000033 E400 ldi r16, (1<<LED_POWER_PORT)
163: 000034 B312 in r17, PORTD
164: 000035 2710 eor r17, r16
165: 000036 BB12 out PORTD, r17
166: 000037 9508 ret
167:
168:
169: ;========================================;
170: ; EEPROM SEGMENT ;
171: ;========================================;
172:
173: .ESEG
174: INFO: .DB "AVR Thermostat. Written by Sergey Yarkov 22.01.2023"
000000 41 56 52 20 54 48 45 52
000008 4D 4F 53 54 41 54 2E 20
000010 57 52 49 54 54 45 4E 20
000018 42 59 20 53 45 52 47 45
000020 59 20 59 41 52 4B 4F 56
000028 20 32 32 2E 30 31 2E 32
000030 30 32 33
List of symbols:
Type nDef nUsed Decimalval Hexval Name
T 1 1 89 59 ATTINY2313A
L 1 2 21 15 RESET_VECT
L 1 0 23 17 MCU_INIT
L 1 2 25 19 INIT_PORTS
L 1 4 29 1D LOOP
L 1 8 38 26 DELAY
L 1 2 39 27 _DEL_1
L 1 2 40 28 _DEL_2
L 1 0 46 2E INFO
L 1 2 1 01 RESET_VECT
L 1 0 3 03 MCU_INIT
L 1 2 6 06 INIT_PORTS
L 1 2 11 0B INIT_USI
L 1 4 12 0C CLOCK_595
L 1 2 19 13 TRANSMIT_595
L 1 2 22 16 _TRANSMIT_595_LOOP
L 1 2 25 19 _TRANSMIT_595_SEND_HIGH
L 1 2 26 1A _TRANSMIT_595_SEND_LOW
L 1 2 26 1A _TRANSMIT_595_PROCEED
L 1 2 32 20 SUBPROGRAM_LED_SHIFTING
L 1 4 35 23 LOOP
L 1 2 39 27 DELAY
L 1 2 41 29 _DELAY_1
L 1 2 42 2A _DELAY_2
L 1 2 51 33 TOGGLE_POWER_LED
L 1 0 0 00 INFO
R 1 2 16 10 TMP_R_A
R 1 1 20 14 COUNTER
C 1 0 23 17 NOW_Y
C 1 0 1 01 NOW_M
C 1 0 24 18 NOW_D
C 1 0 44950 AF96 NOW_I
C 1 3 6 06 LED_POWER_PORT
C 1 0 28 1C NOW_D
C 1 0 44954 AF9A NOW_I
C 1 2 6 06 LED_POWER_PORT
C 1 2 0 00 CLOCK_PIN
C 1 1 1 01 LATCH_PIN
C 1 1 2 02 DATA_PIN
No macros.
Program : 46 words.
Constants : 26 words.
Total program memory: 72 words.
Eeprom space : 0 bytes.
Program : 56 words.
Constants : 0 words.
Total program memory: 56 words.
Eeprom space : 51 bytes.
Data segment : 0 bytes.
Compilation completed, no errors.
Compilation ended 24.01.2023, 01:15:04
Compilation ended 28.01.2023, 02:47:03

View File

@ -1,11 +1,10 @@
/avr_sim_project_file
/home/sergeyyarkov/Documents/Applications/attiny2313a_thermostat/firmware.asm
mainasm=firmware.asm
file=firmware.lst,98,9,55
file=firmware.lst,120,20,63
file=firmware.asm,1,1,1
clock=12000000, Div8
device-type=ATtiny2313A
device-package=20-pin-PDIP_SOIC
include=firmware.asm B89
windows=acepstwz
windows=acePStwz
alert1=0,0,-1,-1,,0,0