From 108f5dbdba6f68a341d6d0a87665b5b28c6f4e5a Mon Sep 17 00:00:00 2001 From: sergeyyarkov Date: Sat, 28 Jan 2023 03:36:06 +0300 Subject: [PATCH] shift register --- firmware.asm | 174 +++++++++++++++++++--------- firmware.eep | 5 + firmware.hex | 17 ++- firmware.lss | 290 ++++++++++++++++++++++++++++++----------------- firmware.lst | 311 +++++++++++++++++++++++++++++++-------------------- firmware.pro | 5 +- 6 files changed, 514 insertions(+), 288 deletions(-) create mode 100644 firmware.eep diff --git a/firmware.asm b/firmware.asm index 777abe8..5228a78 100644 --- a/firmware.asm +++ b/firmware.asm @@ -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< 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< 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< 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<