From 953b7886db1b5b49b0f860f74613bec57dd0658b Mon Sep 17 00:00:00 2001 From: sergeyyarkov Date: Fri, 9 Jun 2023 23:05:42 +0300 Subject: [PATCH] three buttons --- build/main.hex | 18 ++--- build/main.lss | 183 ++++++++++++++++++++++++++++++------------------- main.asm | 115 +++++++++++++++++++++---------- main.hex | 12 ++-- main.lst | 181 +++++++++++++++++++++++++++++++++--------------- main.pro | 11 ++- 6 files changed, 338 insertions(+), 182 deletions(-) diff --git a/build/main.hex b/build/main.hex index a3ca65d..05da671 100644 --- a/build/main.hex +++ b/build/main.hex @@ -1,10 +1,12 @@ :020000020000FC -:020000000FC02F -:1000040000C01F931FB729B3232739B326FF03C0AA -:1000140000C0CE9B1CD01FBF1F9118950FED0DBFC4 -:1000240000E80ABB00E40BBB00E808B900E20BBF20 -:100034003FEF78940000FECF0F931F931FEF04E669 -:100044000A95F1F71A95D9F71F910F910895F4DFE6 -:100054000F931F9319B300E810271BBB1F910F9137 -:020064000895FD +:0200000022C01C +:1000040000C00F931F931FB729B3232739B324FFCD +:1000140006C000C022D007E0CC9B2AD00EC023FF2C +:1000240006C000C01AD006E0CB9B22D006C022FF37 +:1000340004C013D005E0CA9B1BD01FBF1F910F91B2 +:1000440018950FED0DBF00EE0ABB0CE10BBB00E1F0 +:100054000BBF3FEF78940000FECF0F931F931FEF69 +:1000640006E90A95F1F71A95D9F71F910F910895AA +:100074000F931F932F9319B3202F01E0000F2A959C +:0E008400E9F710271BBB2F911F910F910895D4 :00000001FF diff --git a/build/main.lss b/build/main.lss index 1e6df94..42b94ae 100644 --- a/build/main.lss +++ b/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<