From 2855e84b11cbd0e22015fc1ae0541e807832fe15 Mon Sep 17 00:00:00 2001 From: sergeyyarkov Date: Sat, 25 Feb 2023 23:38:49 +0300 Subject: [PATCH] display digits --- .gitignore | 12 +- Makefile | 9 ++ README.md | 0 firmware.asm | 207 +++++++++++++++++------- firmware.hex | 16 +- firmware.lss | 312 +++++++++++++++++++++++------------- firmware.lst | 436 ++++++++++++++++++++++++++++++--------------------- firmware.pro | 6 +- 8 files changed, 631 insertions(+), 367 deletions(-) create mode 100644 Makefile create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 46f42f8..17f1867 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1 @@ -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps +NOTES.md \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ff6ecd4 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +SRC_FILE = firmware +MCU = t2313 +PROGRAMMER = usbtiny + +build: + avrasm2 -fI -W+ie $(SRC_FILE).asm -l $(SRC_FILE).lss + +flash: + avrdude -c $(PROGRAMMER) -p $(MCU) -U flash:w:$(SRC_FILE).hex:i \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/firmware.asm b/firmware.asm index bcf127d..b68ed81 100644 --- a/firmware.asm +++ b/firmware.asm @@ -16,16 +16,34 @@ .DEF TEMP_REG_A = r16 .DEF TEMP_REG_B = r17 -.DEF COUNTER = r20 ;========================================; ; LABELS ; ;========================================; -.EQU LED_POWER_PORT = PD6 -.EQU USI_LATCH_PIN = PB0 ; ST_CP on 74HC595 -.EQU USI_DO_PIN = PB6 ; DS on 74HC595 -.EQU USI_CLK_PIN = PB7 ; SH_CP on 74HC595 +.EQU DIGIT_1_PIN = PD2 +.EQU DIGIT_2_PIN = PD3 +.EQU DIGIT_3_PIN = PD4 +.EQU DIGIT_4_PIN = PD5 + +.EQU LED_POWER_PIN = PD6 + +.EQU USI_LATCH_PIN = PB0 ; ST_CP on 74HC595 +.EQU USI_DO_PIN = PB6 ; DS on 74HC595 +.EQU USI_CLK_PIN = PB7 ; SH_CP on 74HC595 + +.EQU MCU_STATE_DEFAULT = 0x01 ; Temperature measurement and threshold comparison +.EQU MCU_STATE_PROGRAM = 0x02 ; Write settings of hysteresis into EEPROM +.EQU MCU_STATE_ERROR = 0x03 ; Cannot read data from temp sensor or something else + +;========================================; +; DATA SEGMENT ; +;========================================; +.DSEG +.ORG SRAM_START + +MCU_STATE: .BYTE 1 +DISPLAY_DIGIT: .BYTE 4 ;========================================; ; CODE SEGMENT ; @@ -38,64 +56,87 @@ ; VECTORS ; ;========================================; -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 +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 TEMP_REG_A, low(RAMEND) + ldi TEMP_REG_A, LOW(RAMEND) out SPL, TEMP_REG_A MCU_INIT: - ;======================================================= - ; POWER LED <------------> PD6 ; - ; - This LED is used to indicate that device ; - ; is working correctly ; - ; ; - ;======================================================= - rcall INIT_PORTS - ldi COUNTER, 0b00000001 - rjmp LOOP - -INIT_PORTS: - ldi r16, (1< OUT PD6 ; + ; - This LED is used to indicate that device ; + ; is working correctly ; + ; 7SEG DIGIT 1 <-------------> OUT PD2 ; + ; 7SEG DIGIT 2 <-------------> OUT PD3 ; + ; 7SEG DIGIT 3 <-------------> OUT PD4 ; + ; 7SEG DIGIT 4 <-------------> OUT PD5 ; + ; ; + ; USI CLOCK PIN <-------------> OUT PB0 ; + ; USI DATA OUT PIN <-------------> OUT PB6 ; + ; USI LATCH PIN <-------------> OUT PB7 ; + ;=======================================================; + ldi r16, (1< USI Toggle Clock (Enable clock generation) ldi TEMP_REG_A, (1< PD6 ; - ; - This LED is used to indicate that device ; - ; is working correctly ; - ; ; - ;======================================================= -000003 d002 rcall INIT_PORTS -000004 e041 ldi COUNTER, 0b00000001 -000005 c013 rjmp LOOP + ;=======================================================; + ; INITIALIZE PORTS ; + ; ; + ; POWER LED <-------------> OUT PD6 ; + ; - This LED is used to indicate that device ; + ; is working correctly ; + ; 7SEG DIGIT 1 <-------------> OUT PD2 ; + ; 7SEG DIGIT 2 <-------------> OUT PD3 ; + ; 7SEG DIGIT 3 <-------------> OUT PD4 ; + ; 7SEG DIGIT 4 <-------------> OUT PD5 ; + ; ; + ; USI CLOCK PIN <-------------> OUT PB0 ; + ; USI DATA OUT PIN <-------------> OUT PB6 ; + ; USI LATCH PIN <-------------> OUT PB7 ; + ;=======================================================; +000003 e70c ldi r16, (1< USI Wire Mode + ; USICS1 <--------------> USI Clock Source Select + ; USICLK <--------------> USI Clock Strobe + ; USITC <--------------> USI Toggle Clock (Enable clock generation) +00001a e10b ldi TEMP_REG_A, (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: INIT_PORTS: - 87: 000006 E400 ldi r16, (1< OUT PD6 ; + 88: ; - This LED is used to indicate that device ; + 89: ; is working correctly ; + 90: ; 7SEG DIGIT 1 <-------------> OUT PD2 ; + 91: ; 7SEG DIGIT 2 <-------------> OUT PD3 ; + 92: ; 7SEG DIGIT 3 <-------------> OUT PD4 ; + 93: ; 7SEG DIGIT 4 <-------------> OUT PD5 ; + 94: ; ; + 95: ; USI CLOCK PIN <-------------> OUT PB0 ; + 96: ; USI DATA OUT PIN <-------------> OUT PB6 ; + 97: ; USI LATCH PIN <-------------> OUT PB7 ; + 98: ;=======================================================; + 99: 000003 E70C ldi r16, (1< USI Wire Mode + 141: ; USICS1 <--------------> USI Clock Source Select + 142: ; USICLK <--------------> USI Clock Strobe + 143: ; USITC <--------------> USI Toggle Clock (Enable clock generation) + 144: 00001E E10B ldi TEMP_REG_A, (1<