mirror of
https://github.com/sergeyyarkov/attiny26l_push-to-toggle.git
synced 2026-10-11 02:08:54 +03:00
three buttons
This commit is contained in:
parent
9ca3fd9a8c
commit
953b7886db
@ -1,10 +1,12 @@
|
||||
:020000020000FC
|
||||
:020000000FC02F
|
||||
:1000040000C01F931FB729B3232739B326FF03C0AA
|
||||
:1000140000C0CE9B1CD01FBF1F9118950FED0DBFC4
|
||||
:1000240000E80ABB00E40BBB00E808B900E20BBF20
|
||||
:100034003FEF78940000FECF0F931F931FEF04E669
|
||||
:100044000A95F1F71A95D9F71F910F910895F4DFE6
|
||||
:100054000F931F9319B300E810271BBB1F910F9137
|
||||
:020064000895FD
|
||||
:0200000022C01C
|
||||
:1000040000C00F931F931FB729B3232739B324FFCD
|
||||
:1000140006C000C022D007E0CC9B2AD00EC023FF2C
|
||||
:1000240006C000C01AD006E0CB9B22D006C022FF37
|
||||
:1000340004C013D005E0CA9B1BD01FBF1F910F91B2
|
||||
:1000440018950FED0DBF00EE0ABB0CE10BBB00E1F0
|
||||
:100054000BBF3FEF78940000FECF0F931F931FEF69
|
||||
:1000640006E90A95F1F71A95D9F71F910F910895AA
|
||||
:100074000F931F932F9319B3202F01E0000F2A959C
|
||||
:0E008400E9F710271BBB2F911F910F910895D4
|
||||
:00000001FF
|
||||
|
||||
183
build/main.lss
183
build/main.lss
@ -1,5 +1,5 @@
|
||||
|
||||
AVRASM ver. 2.2.7 main.asm Thu Jun 08 22:45:48 2023
|
||||
AVRASM ver. 2.2.7 main.asm Fri Jun 09 23:03:44 2023
|
||||
|
||||
main.asm(1): Including file 'tn26def.inc'
|
||||
main.asm(1): Including file 'tn26def.inc'
|
||||
@ -548,14 +548,24 @@ main.asm(1): Including file 'tn26def.inc'
|
||||
; ***** END OF FILE ******************************************************
|
||||
.LIST
|
||||
|
||||
; **** LABLES ****************************************************
|
||||
; **** REGISTERS *************************************************
|
||||
|
||||
.DEF SW_FLAGS = r20
|
||||
.DEF PC_HISTORY = r19
|
||||
|
||||
.EQU LED_PORT = PA7
|
||||
.EQU SW_PORT = PA6
|
||||
; **** LABLES ****************************************************
|
||||
|
||||
.EQU LED_PORT = PORTA
|
||||
.EQU LED_PIN = PINA
|
||||
.EQU LED_0_PIN = PA7
|
||||
.EQU LED_1_PIN = PA6
|
||||
.EQU LED_2_PIN = PA5
|
||||
|
||||
.EQU SW_PORT = PORTA
|
||||
.EQU SW_PIN = PINA
|
||||
.EQU SW_0_PIN = PA4
|
||||
.EQU SW_1_PIN = PA3
|
||||
.EQU SW_2_PIN = PA2
|
||||
|
||||
; **** CODE SEGMENT **********************************************
|
||||
|
||||
@ -564,94 +574,123 @@ main.asm(1): Including file 'tn26def.inc'
|
||||
; **** VECTORS ***************************************************
|
||||
.ORG 0x00
|
||||
|
||||
000000 c00f rjmp RESET_vect
|
||||
000000 c022 rjmp RESET_vect
|
||||
|
||||
.ORG 0x02
|
||||
|
||||
000002 c000 rjmp PIN_CHANGE_vect
|
||||
|
||||
PIN_CHANGE_vect:
|
||||
000003 931f push r17
|
||||
000004 b71f in r17, SREG
|
||||
000003 930f push r16
|
||||
000004 931f push r17
|
||||
000005 b71f in r17, SREG
|
||||
|
||||
000005 b329 in r18, PINA
|
||||
000006 2723 eor r18, PC_HISTORY
|
||||
000007 b339 in PC_HISTORY, PINA
|
||||
000006 b329 in r18, PINA
|
||||
000007 2723 eor r18, PC_HISTORY
|
||||
000008 b339 in PC_HISTORY, PINA
|
||||
|
||||
000008 ff26 sbrs r18, SW_PORT
|
||||
000009 c003 rjmp _sw_exit
|
||||
00000a c000 rjmp _sw_0
|
||||
_sw_0_check:
|
||||
000009 ff24 sbrs r18, SW_0_PIN
|
||||
00000a c006 rjmp _sw_1_check
|
||||
00000b c000 rjmp _sw_0_handler
|
||||
|
||||
_sw_0:
|
||||
00000b 9bce sbis PINA, SW_PORT
|
||||
00000c d01c rcall TOGGLE_LED
|
||||
; then exit
|
||||
_sw_0_handler:
|
||||
00000c d022 rcall DEBOUNCE_SW
|
||||
00000d e007 ldi r16, LED_0_PIN
|
||||
00000e 9bcc sbis SW_PIN, SW_0_PIN
|
||||
00000f d02a rcall TOGGLE_LED
|
||||
000010 c00e rjmp _sw_exit
|
||||
|
||||
_sw_1_check:
|
||||
000011 ff23 sbrs r18, SW_1_PIN
|
||||
000012 c006 rjmp _sw_2_check
|
||||
000013 c000 rjmp _sw_1_handler
|
||||
|
||||
_sw_1_handler:
|
||||
000014 d01a rcall DEBOUNCE_SW
|
||||
000015 e006 ldi r16, LED_1_PIN
|
||||
000016 9bcb sbis SW_PIN, SW_1_PIN
|
||||
000017 d022 rcall TOGGLE_LED
|
||||
000018 c006 rjmp _sw_exit
|
||||
|
||||
_sw_2_check:
|
||||
000019 ff22 sbrs r18, SW_2_PIN
|
||||
00001a c004 rjmp _sw_exit
|
||||
|
||||
_sw_2_handler:
|
||||
00001b d013 rcall DEBOUNCE_SW
|
||||
00001c e005 ldi r16, LED_2_PIN
|
||||
00001d 9bca sbis SW_PIN, SW_2_PIN
|
||||
00001e d01b rcall TOGGLE_LED
|
||||
|
||||
_sw_exit:
|
||||
00000d bf1f out SREG, r17
|
||||
00000e 911f pop r17
|
||||
00000f 9518 reti
|
||||
00001f bf1f out SREG, r17
|
||||
|
||||
000020 911f pop r17
|
||||
000021 910f pop r16
|
||||
000022 9518 reti
|
||||
|
||||
RESET_vect:
|
||||
000010 ed0f ldi r16, RAMEND
|
||||
000011 bf0d out SP, r16
|
||||
|
||||
000023 ed0f ldi r16, RAMEND
|
||||
000024 bf0d out SP, r16
|
||||
|
||||
MCU_INIT:
|
||||
000012 e800 ldi r16, (1<<LED_PORT) | (0<<SW_PORT)
|
||||
000013 bb0a out DDRA, r16
|
||||
000025 ee00 ldi r16, (1<<LED_0_PIN) | (1<<LED_1_PIN) | (1<<LED_2_PIN) | (0<<SW_0_PIN) | (0<<SW_1_PIN) | (0<<SW_2_PIN)
|
||||
000026 bb0a out DDRA, r16
|
||||
|
||||
000014 e400 ldi r16, (1<<SW_PORT)
|
||||
000015 bb0b out PORTA, r16
|
||||
|
||||
; First, turn off comparator to enable pin change interrupt
|
||||
000016 e800 ldi r16, (1<<ACD)
|
||||
000017 b908 out ACSR, r16
|
||||
000027 e10c ldi r16, (1<<SW_0_PIN) | (1<<SW_1_PIN) | (1<<SW_2_PIN)
|
||||
000028 bb0b out PORTA, r16
|
||||
|
||||
; Enable pin change interrupt
|
||||
000018 e200 ldi r16, (1<<PCIE1)
|
||||
000019 bf0b out GIMSK, r16
|
||||
000029 e100 ldi r16, (1<<PCIE0)
|
||||
00002a bf0b out GIMSK, r16
|
||||
|
||||
00001a ef3f ldi PC_HISTORY, 0xff
|
||||
00002b ef3f ldi PC_HISTORY, 0xff
|
||||
|
||||
00001b 9478 sei
|
||||
00002c 9478 sei
|
||||
|
||||
LOOP:
|
||||
00001c 0000 nop
|
||||
00001d cffe rjmp LOOP
|
||||
00002d 0000 nop
|
||||
00002e cffe rjmp LOOP
|
||||
|
||||
delay: ; FOR 1 MHz
|
||||
00001e 930f push r16
|
||||
00001f 931f push r17
|
||||
DEBOUNCE_SW: ; FOR 1 MHz
|
||||
00002f 930f push r16
|
||||
000030 931f push r17
|
||||
|
||||
000020 ef1f ldi r17, 255
|
||||
_loop_0:
|
||||
000021 e604 ldi r16, 100
|
||||
_dec_0:
|
||||
000022 950a dec r16
|
||||
000023 f7f1 brne _dec_0
|
||||
_loop_1:
|
||||
000024 951a dec r17
|
||||
000025 f7d9 brne _loop_0
|
||||
000031 ef1f ldi r17, 255
|
||||
_loop_0:
|
||||
000032 e906 ldi r16, 150
|
||||
_dec_0:
|
||||
000033 950a dec r16
|
||||
000034 f7f1 brne _dec_0
|
||||
_loop_1:
|
||||
000035 951a dec r17
|
||||
000036 f7d9 brne _loop_0
|
||||
|
||||
000026 911f pop r17
|
||||
000027 910f pop r16
|
||||
000028 9508 ret
|
||||
000037 911f pop r17
|
||||
000038 910f pop r16
|
||||
000039 9508 ret
|
||||
|
||||
TOGGLE_LED:
|
||||
000029 dff4 rcall delay
|
||||
00002a 930f push r16
|
||||
00002b 931f push r17
|
||||
00003a 930f push r16
|
||||
00003b 931f push r17
|
||||
00003c 932f push r18
|
||||
|
||||
00002c b319 in r17, PINA
|
||||
00003d b319 in r17, PINA
|
||||
|
||||
00002d e800 ldi r16, (1<<LED_PORT)
|
||||
00002e 2710 eor r17, r16
|
||||
00002f bb1b out PORTA, r17
|
||||
00003e 2f20 mov r18, r16
|
||||
00003f e001 ldi r16, 0x01
|
||||
_toggle_led_shift:
|
||||
000040 0f00 lsl r16
|
||||
000041 952a dec r18
|
||||
000042 f7e9 brne _toggle_led_shift
|
||||
|
||||
000030 911f pop r17
|
||||
000031 910f pop r16
|
||||
000032 9508 ret
|
||||
000043 2710 eor r17, r16
|
||||
000044 bb1b out PORTA, r17
|
||||
|
||||
000045 912f pop r18
|
||||
000046 911f pop r17
|
||||
000047 910f pop r16
|
||||
|
||||
|
||||
RESOURCE USE INFORMATION
|
||||
@ -671,7 +710,7 @@ counted separately from r26..r31 here.
|
||||
"ATtiny26" 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: 18 r17: 13 r18: 3 r19: 3 r20: 0
|
||||
r13: 0 r14: 0 r15: 0 r16: 23 r17: 13 r18: 9 r19: 3 r20: 0
|
||||
r21: 0 r22: 0 r23: 0 r24: 0 r25: 0 r26: 0 r27: 0 r28: 0
|
||||
r29: 0 r30: 0 r31: 0
|
||||
Registers used: 4 out of 35 (11.4%)
|
||||
@ -680,27 +719,27 @@ Registers used: 4 out of 35 (11.4%)
|
||||
.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 breq : 0 brge : 0 brhc : 0 brhs : 0
|
||||
brid : 0 brie : 0 brlo : 0 brlt : 0 brmi : 0 brne : 2
|
||||
brid : 0 brie : 0 brlo : 0 brlt : 0 brmi : 0 brne : 3
|
||||
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 clv : 0
|
||||
clz : 0 com : 0 cp : 0 cpc : 0 cpi : 0 cpse : 0
|
||||
dec : 2 eor : 2 icall : 0 ijmp : 0 in : 4 inc : 0
|
||||
ld : 0 ldd : 0 ldi : 9 lds : 0 lpm : 0 lsl : 0
|
||||
lsr : 0 mov : 0 neg : 0 nop : 1 or : 0 ori : 0
|
||||
out : 7 pop : 5 push : 5 rcall : 2 ret : 2 reti : 1
|
||||
rjmp : 5 rol : 0 ror : 0 sbc : 0 sbci : 0 sbi : 0
|
||||
sbic : 0 sbis : 1 sbiw : 0 sbr : 0 sbrc : 0 sbrs : 1
|
||||
dec : 3 eor : 2 icall : 0 ijmp : 0 in : 4 inc : 0
|
||||
ld : 0 ldd : 0 ldi : 11 lds : 0 lpm : 0 lsl : 1
|
||||
lsr : 0 mov : 1 neg : 0 nop : 1 or : 0 ori : 0
|
||||
out : 6 pop : 7 push : 7 rcall : 6 ret : 2 reti : 1
|
||||
rjmp : 10 rol : 0 ror : 0 sbc : 0 sbci : 0 sbi : 0
|
||||
sbic : 0 sbis : 3 sbiw : 0 sbr : 0 sbrc : 0 sbrs : 3
|
||||
sec : 0 seh : 0 sei : 1 sen : 0 ser : 0 ses : 0
|
||||
set : 0 sev : 0 sez : 0 sleep : 0 st : 0 std : 0
|
||||
sts : 0 sub : 0 subi : 0 swap : 0 tst : 0 wdr : 0
|
||||
|
||||
Instructions used: 16 out of 102 (15.7%)
|
||||
Instructions used: 18 out of 102 (17.6%)
|
||||
|
||||
"ATtiny26" memory use summary [bytes]:
|
||||
Segment Begin End Code Data Used Size Use%
|
||||
---------------------------------------------------------------
|
||||
[.cseg] 0x000000 0x000066 100 0 100 2048 4.9%
|
||||
[.cseg] 0x000000 0x000092 144 0 144 2048 7.0%
|
||||
[.dseg] 0x000060 0x000060 0 0 0 128 0.0%
|
||||
[.eseg] 0x000000 0x000000 0 0 0 128 0.0%
|
||||
|
||||
|
||||
113
main.asm
113
main.asm
@ -1,14 +1,23 @@
|
||||
.INCLUDE "tn26def.inc"
|
||||
.LIST
|
||||
|
||||
; **** LABLES ****************************************************
|
||||
; **** REGISTERS *************************************************
|
||||
|
||||
.DEF SW_FLAGS = r20
|
||||
.DEF PC_HISTORY = r19
|
||||
|
||||
.EQU LED_PORT = PA7
|
||||
.EQU SW_PORT = PA6
|
||||
; **** LABLES ****************************************************
|
||||
|
||||
.EQU LED_PORT = PORTA
|
||||
.EQU LED_PIN = PINA
|
||||
.EQU LED_0_PIN = PA7
|
||||
.EQU LED_1_PIN = PA6
|
||||
.EQU LED_2_PIN = PA5
|
||||
|
||||
.EQU SW_PORT = PORTA
|
||||
.EQU SW_PIN = PINA
|
||||
.EQU SW_0_PIN = PA4
|
||||
.EQU SW_1_PIN = PA3
|
||||
.EQU SW_2_PIN = PA2
|
||||
|
||||
; **** CODE SEGMENT **********************************************
|
||||
|
||||
@ -24,45 +33,67 @@ rjmp RESET_vect
|
||||
rjmp PIN_CHANGE_vect
|
||||
|
||||
PIN_CHANGE_vect:
|
||||
push r16
|
||||
push r17
|
||||
in r17, SREG
|
||||
|
||||
in r18, PINA
|
||||
eor r18, PC_HISTORY
|
||||
in PC_HISTORY, PINA
|
||||
in r18, PINA
|
||||
eor r18, PC_HISTORY
|
||||
in PC_HISTORY, PINA
|
||||
|
||||
sbrs r18, SW_PORT
|
||||
rjmp _sw_exit
|
||||
rjmp _sw_0_handler
|
||||
_sw_0_check:
|
||||
sbrs r18, SW_0_PIN
|
||||
rjmp _sw_1_check
|
||||
rjmp _sw_0_handler
|
||||
|
||||
_sw_0_handler:
|
||||
sbis PINA, SW_PORT
|
||||
rcall TOGGLE_LED
|
||||
; then exit
|
||||
rcall DEBOUNCE_SW
|
||||
ldi r16, LED_0_PIN
|
||||
sbis SW_PIN, SW_0_PIN
|
||||
rcall TOGGLE_LED
|
||||
rjmp _sw_exit
|
||||
|
||||
_sw_1_check:
|
||||
sbrs r18, SW_1_PIN
|
||||
rjmp _sw_2_check
|
||||
rjmp _sw_1_handler
|
||||
|
||||
_sw_1_handler:
|
||||
rcall DEBOUNCE_SW
|
||||
ldi r16, LED_1_PIN
|
||||
sbis SW_PIN, SW_1_PIN
|
||||
rcall TOGGLE_LED
|
||||
rjmp _sw_exit
|
||||
|
||||
_sw_2_check:
|
||||
sbrs r18, SW_2_PIN
|
||||
rjmp _sw_exit
|
||||
|
||||
_sw_2_handler:
|
||||
rcall DEBOUNCE_SW
|
||||
ldi r16, LED_2_PIN
|
||||
sbis SW_PIN, SW_2_PIN
|
||||
rcall TOGGLE_LED
|
||||
|
||||
_sw_exit:
|
||||
out SREG, r17
|
||||
out SREG, r17
|
||||
|
||||
pop r17
|
||||
pop r16
|
||||
reti
|
||||
|
||||
RESET_vect:
|
||||
ldi r16, RAMEND
|
||||
out SP, r16
|
||||
|
||||
|
||||
MCU_INIT:
|
||||
ldi r16, (1<<LED_PORT) | (0<<SW_PORT)
|
||||
ldi r16, (1<<LED_0_PIN) | (1<<LED_1_PIN) | (1<<LED_2_PIN) | (0<<SW_0_PIN) | (0<<SW_1_PIN) | (0<<SW_2_PIN)
|
||||
out DDRA, r16
|
||||
|
||||
ldi r16, (1<<SW_PORT)
|
||||
ldi r16, (1<<SW_0_PIN) | (1<<SW_1_PIN) | (1<<SW_2_PIN)
|
||||
out PORTA, r16
|
||||
|
||||
; First, turn off comparator to enable pin change interrupt (only for tiny26l)
|
||||
ldi r16, (1<<ACD)
|
||||
out ACSR, r16
|
||||
|
||||
; Enable pin change interrupt
|
||||
ldi r16, (1<<PCIE1)
|
||||
ldi r16, (1<<PCIE0)
|
||||
out GIMSK, r16
|
||||
|
||||
ldi PC_HISTORY, 0xff
|
||||
@ -71,21 +102,21 @@ MCU_INIT:
|
||||
|
||||
LOOP:
|
||||
nop
|
||||
rjmp LOOP
|
||||
rjmp LOOP
|
||||
|
||||
delay: ; FOR 1 MHz
|
||||
push r16
|
||||
push r17
|
||||
DEBOUNCE_SW: ; FOR 1 MHz
|
||||
push r16
|
||||
push r17
|
||||
|
||||
ldi r17, 255
|
||||
_loop_0:
|
||||
ldi r16, 100
|
||||
_dec_0:
|
||||
dec r16
|
||||
brne _dec_0
|
||||
_loop_1:
|
||||
dec r17
|
||||
brne _loop_0
|
||||
ldi r17, 255
|
||||
_loop_0:
|
||||
ldi r16, 150
|
||||
_dec_0:
|
||||
dec r16
|
||||
brne _dec_0
|
||||
_loop_1:
|
||||
dec r17
|
||||
brne _loop_0
|
||||
|
||||
pop r17
|
||||
pop r16
|
||||
@ -94,13 +125,21 @@ ret
|
||||
TOGGLE_LED:
|
||||
push r16
|
||||
push r17
|
||||
push r18
|
||||
|
||||
in r17, PINA
|
||||
|
||||
ldi r16, (1<<LED_PORT)
|
||||
mov r18, r16
|
||||
ldi r16, 0x01
|
||||
_toggle_led_shift:
|
||||
lsl r16
|
||||
dec r18
|
||||
brne _toggle_led_shift
|
||||
|
||||
eor r17, r16
|
||||
out PORTA, r17
|
||||
|
||||
pop r18
|
||||
pop r17
|
||||
pop r16
|
||||
ret
|
||||
12
main.hex
12
main.hex
@ -1,6 +1,10 @@
|
||||
:020000020000FC
|
||||
:0200000005C039
|
||||
:1000040000C000E80BBB18950FED0DBF789400E815
|
||||
:100014000ABB00E40BBB00E20BBF0000FECF00E80C
|
||||
:040024000BBB189565
|
||||
:0200000010C02E
|
||||
:1000040000C01F931FB729B3232739B320FF04C0AF
|
||||
:1000140000C015D0C89B1ED01FBF1F9118950FEDAF
|
||||
:100024000DBF00EE0ABB00E008BB01E008BB00E81E
|
||||
:1000340008B900E30BBF3FEF78940000FECF0F93A5
|
||||
:100044001F931FEF06E90A95F1F71A95D9F71F9147
|
||||
:100054000F9108950F931F9319B300E810271BBB4A
|
||||
:060064001F910F910895A9
|
||||
:00000001FF
|
||||
|
||||
181
main.lst
181
main.lst
@ -5,7 +5,7 @@ Path: /home/sergeyyarkov/Documents/Projects/Firmwares/AVR/attiny26l_push-
|
||||
Source file: main.asm
|
||||
Hex file: main.hex
|
||||
Eeprom file: main.eep
|
||||
Compiled: 08.06.2023, 19:30:17
|
||||
Compiled: 09.06.2023, 21:36:55
|
||||
Pass: 2
|
||||
|
||||
1: .INCLUDE "tn26def.inc"
|
||||
@ -16,75 +16,142 @@ Pass: 2
|
||||
3:
|
||||
4: ; **** LABLES ****************************************************
|
||||
5:
|
||||
6: .EQU LED_PORT = PA7
|
||||
7: .EQU SW_PORT = PA6
|
||||
6: .DEF SW_FLAGS = r20
|
||||
7: .DEF PC_HISTORY = r19
|
||||
8:
|
||||
9:
|
||||
10: ; **** CODE SEGMENT **********************************************
|
||||
9: .EQU LED_PORT = PA7
|
||||
10: .EQU SW_0_PIN = PB0
|
||||
11:
|
||||
12: .CSEG
|
||||
13:
|
||||
14: ; **** VECTORS ***************************************************
|
||||
15: .ORG 0x00
|
||||
12:
|
||||
13: ; **** CODE SEGMENT **********************************************
|
||||
14:
|
||||
15: .CSEG
|
||||
16:
|
||||
17: 000000 C005 rjmp RESET_vect
|
||||
18:
|
||||
19: .ORG $002
|
||||
20:
|
||||
21: 000002 C000 rjmp PIN_CHANGE_vect
|
||||
22:
|
||||
23: PIN_CHANGE_vect:
|
||||
24: ; rcall ENABLE_LED
|
||||
25: 000003 E800 ldi r16, (1<<LED_PORT)
|
||||
26: 000004 BB0B out PORTA, r16
|
||||
27: 000005 9518 reti
|
||||
28:
|
||||
29: RESET_vect:
|
||||
30: 000006 ED0F ldi r16, RAMEND
|
||||
31: 000007 BF0D out SP, r16
|
||||
32:
|
||||
33: 000008 9478 sei
|
||||
34:
|
||||
35: MCU_INIT:
|
||||
36: 000009 E800 ldi r16, (1<<LED_PORT) | (0<<SW_PORT)
|
||||
37: 00000A BB0A out DDRA, r16
|
||||
38:
|
||||
39: 00000B E400 ldi r16, (1<<SW_PORT)
|
||||
40: 00000C BB0B out PORTA, r16
|
||||
41:
|
||||
42: 00000D E200 ldi r16, (1<<PCIE1)
|
||||
43: 00000E BF0B out GIMSK, r16
|
||||
44:
|
||||
45:
|
||||
46: LOOP:
|
||||
47: 00000F 0000 nop
|
||||
48: 000010 CFFE rjmp LOOP
|
||||
49:
|
||||
50: ENABLE_LED:
|
||||
51: 000011 E800 ldi r16, (1<<LED_PORT)
|
||||
52: 000012 BB0B out PORTA, r16
|
||||
53: 000013 9518 reti
|
||||
17: ; **** VECTORS ***************************************************
|
||||
18: .ORG 0x00
|
||||
19:
|
||||
20: 000000 C010 rjmp RESET_vect
|
||||
21:
|
||||
22: .ORG 0x02
|
||||
23:
|
||||
24: 000002 C000 rjmp PIN_CHANGE_vect
|
||||
25:
|
||||
26: PIN_CHANGE_vect:
|
||||
27: 000003 931F push r17
|
||||
28: 000004 B71F in r17, SREG
|
||||
29:
|
||||
30: 000005 B329 in r18, PINA
|
||||
31: 000006 2723 eor r18, PC_HISTORY
|
||||
32: 000007 B339 in PC_HISTORY, PINA
|
||||
33:
|
||||
34: 000008 FF20 sbrs r18, SW_0_PIN
|
||||
35: 000009 C004 rjmp _sw_exit
|
||||
36: 00000A C000 rjmp _sw_0_handler
|
||||
37:
|
||||
38: _sw_0_handler:
|
||||
39: 00000B D015 rcall delay
|
||||
40: 00000C 9BC8 sbis PINA, SW_0_PIN
|
||||
41: 00000D D01E rcall TOGGLE_LED
|
||||
42: ; then exit
|
||||
43:
|
||||
44: _sw_exit:
|
||||
45: 00000E BF1F out SREG, r17
|
||||
46: 00000F 911F pop r17
|
||||
47: 000010 9518 reti
|
||||
48:
|
||||
49: RESET_vect:
|
||||
50: 000011 ED0F ldi r16, RAMEND
|
||||
51: 000012 BF0D out SP, r16
|
||||
52:
|
||||
53:
|
||||
54: MCU_INIT:
|
||||
55: 000013 EE00 ldi r16, (1<<PA7) | (1<<PA6) | (1<<PA5)
|
||||
56: 000014 BB0A out DDRA, r16
|
||||
57:
|
||||
58: 000015 E000 ldi r16, (0<<PB0)
|
||||
59: 000016 BB08 out PORTB, r16
|
||||
60:
|
||||
61: 000017 E001 ldi r16, (1<<PB0)
|
||||
62: 000018 BB08 out PORTB, r16
|
||||
63:
|
||||
64: ; First, turn off comparator to enable pin change interrupt (only for tiny26l)
|
||||
65: 000019 E800 ldi r16, (1<<ACD)
|
||||
66: 00001A B908 out ACSR, r16
|
||||
67:
|
||||
68: ; Enable pin change interrupt
|
||||
69: 00001B E300 ldi r16, (1<<PCIE0) | (1<<PCIE1)
|
||||
70: 00001C BF0B out GIMSK, r16
|
||||
71:
|
||||
72: 00001D EF3F ldi PC_HISTORY, 0xff
|
||||
73:
|
||||
74: 00001E 9478 sei
|
||||
75:
|
||||
76: LOOP:
|
||||
77: ; rcall TOGGLE_LED
|
||||
78: ; rcall delay
|
||||
79: 00001F 0000 nop
|
||||
80: 000020 CFFE rjmp LOOP
|
||||
81:
|
||||
82: delay: ; FOR 1 MHz
|
||||
83: 000021 930F push r16
|
||||
84: 000022 931F push r17
|
||||
85:
|
||||
86: 000023 EF1F ldi r17, 255
|
||||
87: _loop_0:
|
||||
88: 000024 E906 ldi r16, 150
|
||||
89: _dec_0:
|
||||
90: 000025 950A dec r16
|
||||
91: 000026 F7F1 brne _dec_0
|
||||
92: _loop_1:
|
||||
93: 000027 951A dec r17
|
||||
94: 000028 F7D9 brne _loop_0
|
||||
95:
|
||||
96: 000029 911F pop r17
|
||||
97: 00002A 910F pop r16
|
||||
98: 00002B 9508 ret
|
||||
99:
|
||||
100: TOGGLE_LED:
|
||||
101: 00002C 930F push r16
|
||||
102: 00002D 931F push r17
|
||||
103:
|
||||
104: 00002E B319 in r17, PINA
|
||||
105:
|
||||
106: 00002F E800 ldi r16, (1<<PA7)
|
||||
107: 000030 2710 eor r17, r16
|
||||
108: 000031 BB1B out PORTA, r17
|
||||
109:
|
||||
110: 000032 911F pop r17
|
||||
111: 000033 910F pop r16
|
||||
112: 000034 9508 ret
|
||||
|
||||
List of symbols:
|
||||
Type nDef nUsed Decimalval Hexval Name
|
||||
T 1 1 27 1B ATTINY26
|
||||
L 1 2 3 03 PIN_CHANGE_VECT
|
||||
L 1 2 6 06 RESET_VECT
|
||||
L 1 0 9 09 MCU_INIT
|
||||
L 1 2 15 0F LOOP
|
||||
L 1 0 17 11 ENABLE_LED
|
||||
L 1 2 11 0B _SW_0_HANDLER
|
||||
L 1 2 14 0E _SW_EXIT
|
||||
L 1 2 17 11 RESET_VECT
|
||||
L 1 0 19 13 MCU_INIT
|
||||
L 1 2 31 1F LOOP
|
||||
L 1 2 33 21 DELAY
|
||||
L 1 2 36 24 _LOOP_0
|
||||
L 1 2 37 25 _DEC_0
|
||||
L 1 0 39 27 _LOOP_1
|
||||
L 1 2 44 2C TOGGLE_LED
|
||||
R 1 0 20 14 SW_FLAGS
|
||||
R 1 3 19 13 PC_HISTORY
|
||||
C 1 0 23 17 NOW_Y
|
||||
C 1 0 6 06 NOW_M
|
||||
C 1 0 8 08 NOW_D
|
||||
C 1 0 45085 B01D NOW_I
|
||||
C 1 3 7 07 LED_PORT
|
||||
C 1 2 6 06 SW_PORT
|
||||
C 1 0 9 09 NOW_D
|
||||
C 1 0 45086 B01E NOW_I
|
||||
C 1 0 7 07 LED_PORT
|
||||
C 1 2 0 00 SW_0_PIN
|
||||
No macros.
|
||||
|
||||
Program : 19 words.
|
||||
Program : 52 words.
|
||||
Constants : 0 words.
|
||||
Total program memory: 19 words.
|
||||
Total program memory: 52 words.
|
||||
Eeprom space : 0 bytes.
|
||||
Data segment : 0 bytes.
|
||||
Compilation completed, no errors.
|
||||
Compilation ended 08.06.2023, 19:30:17
|
||||
Compilation ended 09.06.2023, 21:36:55
|
||||
|
||||
11
main.pro
11
main.pro
@ -1,8 +1,13 @@
|
||||
/avr_sim_project_file
|
||||
/home/sergeyyarkov/Documents/Projects/Firmwares/AVR/attiny26l_push-to-toggle/main.asm
|
||||
mainasm=main.asm
|
||||
file=main.lst,60,1,1
|
||||
file=main.asm,1,1,1
|
||||
clock=0, Div8
|
||||
clock=1000000, Div8
|
||||
device-type=ATtiny26
|
||||
windows=acepstwz
|
||||
alert1=0,0,-1,0,,0,0
|
||||
device-package=32-pin-MLF
|
||||
windows=acePstwz
|
||||
alert1=0,0,-1,-1,,0,0
|
||||
adcvref=5.0000
|
||||
adcvop=5.0000
|
||||
adcch=0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user