; C_ESR_Meter_Eng ; Version 1.1 ; Author: Kelehsashvili VA ; Version of the program for external interrupts from the negative level. ; Connection with the LCD on the basis of time delay. ; Switching to the upper range only by the counter overflow timer. ; To exit a loop waiting for the termination of U2. ; Frequency 20MHz. ; Formation of delays without using the stack. ; Countdown to 262 144 on one edge. ; LCD nerusifitsirovanny. ; To coordinate with the LCD on the HD44780U uvelichina length of the delay between transmission ; And the second in command to send commands to the sub-LCD (lcd_out) . Include "tn2313def.inc"; fitting the description file . List; Turning Listing . Def sotye = R0; number of hundredths (1) . Def desyatye = R1; number of tenths (2) . Def edinicy = R2; number of units (3) . Def desyatki = R3; number ten (4) . Def sotni = R4; number hundreds of thousands of (5) . Def tyshi = R5; Number of thousands (6) . Def des_tysh = R6; Number of thousands (7) . Def a1 = R7; 1-byte variable a (low byte) . Def a2 = R8; 2nd byte variable a . Def a3 = R9; third byte of a variable . Def b1 = R10; 1-byte variable b (low byte) . Def b2 = R11; 2nd byte of b . Def b3 = R12; 3rd byte of b . Def c1 = R13; 1st byte of the variable c (low byte) . Def c2 = R14; 2nd byte of c . Def c3 = R15; third byte of c ;------------------------------------------------- ------- . Def c4 = R16; four-byte variable c . Def temp = R17; definition of the main working register . Def temp2 = R18; definition of the second working register . Def lcd = R19; Determination register to access the LCD . Def z1 = R20; 1st byte of the variable z (low byte) . Def z2 = R21; 2nd byte variable z . Def z3 = R22; third byte of the variable z . Def z4 = R23; four-byte variable z . Def k_del = R24; Register amendments Coefficient division timer . Def tok_zar = R25; Register magnitude of the current charge . Def autoff = R28; register counter auto-off (also known as YL) . Def autoff2 = R29; register limit of measurement in the Faraday (aka YH) ;------------------------------------------------- ------- . Equ const1b = 8400; constant transfer results in a greater capacity for power (32768) . Equ const1m = 8965; constant transfer results in a container for a small current (524288) . Equ const2 = 1951; constant 100 * U1/Ib . Equ const3 = 3901; constant 100 * U2/Ib . Equ const4 = 129; constant speed reference USART (9600 bit / s) . Equ ESRmax = 2001; threshold maximum value of ESR (20,00 ohms) . Equ porog1 = 32 700; switching threshold for the lower limit (of U2) . Equ porog2 = 15 001; switching threshold at low current (150 uF) . Equ porog3 = 2001; switching threshold limit at low current (20 uF) . Equ d20m = 65535; value of the pause (~ 20 ms at 20 MHz) (beats-9) / 6 . Equ d3m = 9999 Value pause duration (~ 3ms at 20MHz) (beats-9) / 6 . Equ d40u = 235; value of the pause (~ 40mks at 20MHz) (beats-4) / 3 . Equ d1u = 6; value of the pause (~ 1mks at 20MHz) (beats-4) / 3 . Equ RS = 2; . Equ E = 3; ;------------------------ Reservation memory EEPROM . Eseg . Org 0x08; installation of the current segment addresses n1_1b: . Byte 1; EEPROM cell for the 1st byte of the amendment for n1 n1_2b: . Byte 2; EEPROM cell for the 2nd Amendment to byte n1 n2_1b: . Byte 3; EEPROM cell for the 1st byte of the amendments to n2 n2_2b: . Byte 4; EEPROM cell for the 2nd Amendment to n2 bytes n2_n1_1b: . Byte 5; EEPROM cell for the 1st byte of the amendment to (n2-n1) n2_n1_2b: . Byte 6; EEPROM cell for the 2nd Amendment to byte (n2-n1) flag: . Byte 7; EEPROM cell for recording the flag amendment calculation ;------------------------ Start code . Cseg . Org 0; setting the current address to zero ;------------------------ Override the interrupt vector start: rjmp init; Go to the beginning of the program rjmp com_U1; External Interrupt 0 rjmp com_U2; External Interrupt 1 reti; Timer / counter 1 capture reti; Timer / Counter 1, the coincidence channel A rjmp ovtim1; Timer / Counter 1 overflow interrupt reti; Counter / Timer 0 overflow interrupt reti; USART interrupt the reception is complete reti; interrupt USART data register empty reti; USART interrupt the transfer is complete reti; interrupt comparator reti; Interruption to change at any contact reti; Timer / Counter 1, the coincidence of the channel in reti; Timer / counter 0 match, the channel in reti; Timer / counter 0 match, the channel A reti; USI ready for launch reti; USI Overflow reti; EEPROM readiness reti; overflow guard timer ;----------------------- Module initialization init: ;----------------------- Initialize stack ldi temp, RAMEND; address selection of the external stack out SPL, temp; record it in the register stack USART Initialization ;----------------------- cli; Globally disables interrupts ldi temp, high (const4); Senior nibble at a constant temp out UBRRH, temp; entry in the register USART baud rate high-order nibble ldi temp, low (const4); Junior nibble at a constant temp out UBRRL, temp; entry in the register exchange rate USART Jr. nibbles ldi temp, 0b00000000; Installing a single exchange rate out UCSRA, temp; ldi temp, 0b00001000; permit the transfer, interrupt prohibition out UCSRB, temp; ldi temp, 0b00000110; Setting mode USART (8-bit async., no parity) out UCSRC, temp; ;----------------------- Initialize ports BB ldi temp, 0b00000100; PA2 to the conclusion, PA0, PA1 to enter out DDRA, temp; ldi temp, 0b00000100; Set PA2, disable the resistors on PA0, PA1 out PORTA, temp; ldi temp, 0b11111101; PB0, PB2 ... PB7 to conclude, PB1 to input out DDRB, temp; ldi temp, 0b00000000; Resets PB1 ... PB7, PB1, and turn on the set resistor PB0 out PORTB, temp; ldi temp, 0b00110011; PD0, PD1, PD4 ... PD5 on output, PD2, PD3, PD6 to enter out DDRD, temp; ldi temp, 0b01111111; Set PD0, PD1, PD4 ... PD5 and include resistors PD2, PD3, PD6 out PORTD, temp; ;----------------------- Initializing timer T1 ldi temp, 0b00000000; stop the timer, the normal mode out TCCR1B, temp; ;----------------------- Initialization comparator ldi temp, 0b01110000; Setting the comparator out ACSR, temp; ;----------------------- Definition interrupt masks ldi temp, 0b00000000; Selecting calling external interrupt PD2 (U1) and PD3 (U2) out MCUCR, temp; ldi temp, 0b00000000; ban on the timer interrupt 1 out TIMSK, temp ldi temp, 0b00000000; ban external interrupts out GIMSK, temp; ;----------------------- Initialize LCD (KS0066) lcd_init: rcall del20m; Call a delay (~ 20ms) rcall del20m; Call a delay (~ 20ms) rcall del20m; Call a delay (~ 20ms) ; Team 0010 sbi PORTB, E; Gate up ldi temp, 0b00101000; Team (strobe up + command) out PORTB, temp; Record command to the port rcall del1u; Call a delay (~ 1mks) cbi PORTB, E; Gate down rcall del40u; Call a delay (~ 40mks) ldi lcd, 0b00101000; Team 0010 and 1000 rcall lcd_com; Call subroutine to send commands to the LCD ldi lcd, 0b00001000; Team 0000 and 1000 rcall lcd_com; Call subroutine to send commands to the LCD ldi lcd, 0b00000001; Team 0000 and 0001 rcall lcd_com; Call subroutine to send commands to the LCD rcall del3m; Call a delay (~ 3ms) ldi lcd, 0b00000110; Team 0000 and 0110 rcall lcd_com; Call subroutine to send commands to the LCD ;----------------------- Start the main program cli; Globally disables interrupts clr k_del; Cleaning k_del clr tok_zar; Cleaning tok_zar clr autoff; Cleaning autoff clr autoff2; Cleaning autoff2 ldi lcd, 0b00001100; enable the display and cursor selection rcall lcd_com; Displaying ;----------------------- Welcome ldi ZL, low (Prvt * 2); Record in ZL LSB address of a cell of the table Prvt (alternate address) ldi ZH, high (Prvt * 2); Record in ZH high byte address of a cell of the table Prvt (alternate address) rcall lcd_all; Call a two-line display on the LCD according to the tables main: clr c3; Cleaning c3 (clearing third byte of the timer counter) sbi PORTD, 0; Turn off the high current charging the capacitor sbi PORTD, 4; low current shutdown the charging sbi PORTD, 5; inclusion of the capacitor discharge clr temp; Resets timer 1 counting register out TCNT1H, temp; out TCNT1L, temp; ;----------------------- Auto and control voltage autoff_check: cpi autoff, 255; Comparison autoff with 255 (~ 4'35 ") breq autoff_check1; If autoff = 255, then at autoff_check1, otherwise further cpi k_del, 4; Comparison k_del 4 brlo autoff_check00; If k_del <4, then at autoff_check00, otherwise further cpi autoff2, 10; autoff2 comparison with 10 (~ 2'17 ") brlo bat_check1; If autoff2 <10, then at bat_check1, otherwise further rjmp autoff_check1; On autoff_check1 autoff_check00: cpi k_del, 3, 3 Compare k_del brlo autoff_check0; If k_del <3, then at autoff_check0, otherwise further cpi autoff2, 31; autoff2 comparison with 31 (~ 2'22 ") brlo bat_check1; If autoff2 <31, then at bat_check1, otherwise further rjmp autoff_check1; On autoff_check1 autoff_check0: cpi autoff2, 100; Comparison autoff2 with 100 (~ 2'17 ") brlo bat_check1; If autoff2 <100, then at bat_check1, otherwise further autoff_check1: Turn off the device ;----------------------- ldi temp, 0b01110000; permit the transition to the Power-Down Mode out MCUCR, temp; sbi PORTB, 0; Power Off sleep; Transition in Power-Down Mode bat_check1: clr z1; Cleaning z1 clr z2; Cleaning z2 ldi temp, 55, 55 in the temp record bat_check2: rcall del20m; Call a delay (~ 20ms) dec temp; Reduce temp to 1 sbis ACSR, ACO; If the output of the comparator 1, the pass mark. command, or further rjmp bat_check3; On bat_check3 inc z1; increase z1 1 rjmp bat_check4; On bat_check4 bat_check3: inc z2; increase z2 1 bat_check4: cpi temp, 0, temp comparison with 0 brne bat_check2; If temp <> 0, then bat_check2, otherwise further cp z1, z2; comparison with z1 z2 brlo pusk_0; If z1 = 2, then pusk_0, otherwise further ldi ZL, low (Gdit * 2); Record in ZL LSB address of a cell of the table Gdit (alternate address) ldi ZH, high (Gdit * 2); Record in ZH high byte address of a cell of the table Gdit (alternate address) ldi temp, 1, display the 1st row rcall lcd_mess; Call a display of messages ldi ZL, low (Gdit * 2); Record in ZL LSB address of a cell of the table Gdit (alternate address) ldi ZH, high (Gdit * 2); Record in ZH high byte address of a cell of the table Gdit (alternate address) ldi temp, 2; Display 2nd line rcall lcd_mess; Call a display of messages pusk_0: Send a message about ;----------------------- limit measure rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xC0; 0xC0 Record in temp or temp, k_del; alteration k_del with temp, temp result in out UDR, temp; transfer from temp to USART rcall USART_ready; Subroutine call waiting ready transmit buffer pusk: ldi temp, 0b01000000; permit an external interrupt only on PD2 (U1) out GIMSK, temp; ldi temp, 0b10000000; Interrupt Enable only the timer 1 overflow out TIMSK, temp; cbi PORTD, 5; shutdown capacitor discharge rcall del1u; Call a delay (~ 1mks), wait a bit close MOSFET sei; globally enables interrupts cpi tok_zar, 1; Comparison tok_zar 1 breq m_tok; If tok_zar = 1, then m_tok, otherwise further ;----------------------- Measurement at high current charge b_tok: ldi temp, 0b00000001; Start timer (clk / 1) add temp, k_del; adjusted Coefficient division timer cbi PORTD, 0; enable the charging out TCCR1B, temp; rjmp cikl; On cikl ;----------------------- Measurement at low current charge m_tok: ldi temp, 0b00000001; Start timer (clk / 1) add temp, k_del; adjusted Coefficient division timer cbi PORTD, 4; enable the charging out TCCR1B, temp; cikl: rjmp cikl; looped ;----------------------- Reducing measurement limit (increased frequency of timer) clk_up: cpi k_del, 0; k_del comparison with 0 breq clk_no_ch; If k_del = 0, then clk_no_ch, otherwise further dec k_del; Reduction Amendment 1 (decrease in the division) rjmp clk_pred; On clk_pred ;----------------------- Increase the limit of measurement (reduction of frequency timer) clk_down: clr tok_zar; Cleaning k_del cpi k_del, 4; Comparison k_del 4. brlo clk_down_0; If k_del <4, then at clk_down_0, otherwise further rjmp step3; Otherwise, the step3 (display messages on BB) clk_down_0: inc k_del; Increase Amendment 1 (increase in the division) clk_pred: ldi ZL, low (Pred * 2); Record in ZL LSB address of a cell of the table Pred (alternate address) ldi ZH, high (Pred * 2); Record in ZH high byte address of a cell of the table Pred (alternate address) rcall lcd_all; Call a two-line display on the LCD according to the tables rcall pred_num; Subroutine call number display limit clr autoff; Cleaning autoff ;----------------------- Send a message to "wait ..." rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xD4; 0xD4 Record in temp out UDR, temp; transfer from temp to USART rcall USART_ready; Subroutine call waiting ready transmit buffer clk_no_ch: rjmp main; On the main ;----------------------- Check the lower threshold (porog1) ; If the counter value is greater than or equal to porog1, then on the amendment (in step4), ; If the counter value is less than porog1, then to check the frequency of the timer (hereinafter referred to step2) step1: ldi z1, low (porog1); Writes low byte porog1 in z1 ldi z2, high (porog1); Sets high byte porog1 in z2 ldi z3, 0, 0, z3 Sets cp b1, z1; Comparison b2 + b1 with z2 + z1 with carry cpc b2, z2; cpc b3, z3; brsh step4; If b3 + b2 + b1 is greater than or equal to z3 + z2 + z1, then at step4, otherwise continue (in step2) Checking the timer frequency ;----------------------- ; If k_del = 0 (clk / 1), then on the amendment (in step4), if k_del <> 0, , Then to reduce the limit of measurement (for clk_up) step2: cpi k_del, 0; k_del comparison with 0 breq step4; If k_del = 0, then the amendment (in step4) rjmp clk_up; Otherwise, the reduction in the limit of measurement (for clk_up) ;----------------------- Display of fault in excess of expectations step3: ldi ZL, low (KZ_Cmx * 2); Record in ZL LSB address of a cell of the table KZ_Cmx (alternate address) ldi ZH, high (KZ_Cmx * 2); Record in ZH high byte address of a cell of the table KZ_Cmx (alternate address) rcall lcd_all; Call a display of two lines in a row on the LCD according to the tables ldi temp, 85; Values ​​1, 3, 5, 15, 17, 51, 85, 255 (at 85 50 sec) add autoff, temp ;----------------------- Messaging "Cx> max" and "ESR = porog2, then on step6_3_1, otherwise further ldi tok_zar, 1, Entry 1 in tok_zar ldi z1, low (porog3); Record low byte porog3 in z1 ldi z2, high (porog3); Record high byte porog3 in z2 cp c1, z1; comparison with c1 z1 cpc c2, z2; comparison with c2 z2 with carry cpc c3, z3; comparison with c3 z3 with carry cpc c4, z4; comparison with c4 z4 with carry brlo step6_3_0; if (c4 + c3 + c2 + c1) 20,0 OM" rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xD2; 0xD2 Record in temp out UDR, temp; transfer from temp to USART rcall USART_ready; Subroutine call waiting ready transmit buffer step8_0: ldi temp, 2; Display 2nd line rcall lcd_mess; Call a display of messages rjmp main; On the main ;----------------------- Binary translation results in the ESR BCD step9: rcall bin2dec; Call a translation of the binary number in binary-coded decimal (ESR) ;----------------------- Displays the second line LCD step10: rcall lcd_2str; Call a second line of LCD display Transfer ;----------------------- 8th ... 11-byte through USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x80; 0x80 Record in temp or desyatki, temp; alteration desyatki with temp, result in desyatki out UDR, desyatki; Transmission desyatki in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x90; 0x90 Record in temp or edinicy, temp; alteration edinicy with temp, result in edinicy out UDR, edinicy; Transmission edinicy in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xA0; 0xA0 Record in temp or desyatye, temp; alteration desyatye with temp, result in desyatye out UDR, desyatye; Transmission desyatye in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xB0; 0xB0 Record in temp or sotye, temp; alteration sotye with temp, result in sotye out UDR, sotye; Transmission sotye in USART rcall USART_ready; Subroutine call waiting ready transmit buffer rjmp main; On the main ;----------------------- Sub-display the first line of LCD lcd_1str: ;----------------------- Display capacity ldi lcd, 0x80; choice familiarity (the beginning of 1st line) rcall lcd_com; Call subroutine to send commands to the LCD ;----------------------- Display "12345" or "2345" clr temp; Cleaning temp cp des_tysh, temp; If the tens of thousands of non-zero, then go to lcd_1str_4 brne lcd_1str_4; otherwise further cp tyshi, temp; If the value of thousands of non-zero, then go to lcd_1str_3 brne lcd_1str_3; otherwise further cp sotni, temp; If the value of hundreds of non-zero, then go to lcd_1str_2 brne lcd_1str_2; otherwise further cp desyatki, temp; If the value of dozens of non-zero, then go to lcd_1str_0 brne lcd_1str_0; otherwise further ;----------------------- Display "5.67" or "45.67" ldi lcd, 0x20; display "" (capacity) rcall lcd_dat; rjmp lcd_1str_1; On lcd_1str_1 lcd_1str_0: cpi k_del, 4; Comparison k_del 4 brne lcd_1str_0_1; If k_del <> 4, then at lcd_1str_0_1 ldi lcd, 0x30; display "0" (capacity) rcall lcd_dat; ldi lcd, 0x2C; Display "," (capacity) rcall lcd_dat; lcd_1str_0_1: ldi lcd, 0x30; Identification code for the number ten (capacity) add lcd, desyatki; rcall lcd_dat; Displays the number of ten (capacity) lcd_1str_1: ldi lcd, 0x30; Identification code for the number of units (capacity) add lcd, edinicy; rcall lcd_dat; Displays the number of units (capacity) cpi k_del, 4; Comparison k_del 4 brne lcd_1str_1_1; If k_del <> 4, then at lcd_1str_1_1 ldi lcd, 0x30; Identification code for the number of tenths (capacity) add lcd, desyatye; rcall lcd_dat; Displays the number of tenths (capacity) ldi lcd, 0x30; Identification code for the number of hundredths (capacity) add lcd, sotye; rcall lcd_dat; Displays the number of hundredths (capacity) ldi lcd, 0x20; display "" (capacity) rcall lcd_dat; rjmp F_lcd; On F_lcd lcd_1str_1_1: ldi lcd, 0x2C; Display "," (capacity) rcall lcd_dat; ldi lcd, 0x30; Identification code for the number of tenths (capacity) add lcd, desyatye; rcall lcd_dat; Displays the number of tenths (capacity) ldi lcd, 0x30; Identification code for the number of hundredths (capacity) add lcd, sotye; rcall lcd_dat; Displays the number of hundredths (capacity) rjmp uF_lcd; On uF_lcd ;----------------------- Display "345.6" lcd_1str_2: ldi lcd, 0x30; Identification code for the number of hundreds (capacity) add lcd, sotni; rcall lcd_dat; Displays the number of hundreds (capacity) ldi lcd, 0x30; Identification code for the number ten (capacity) add lcd, desyatki; rcall lcd_dat; Displays the number of ten (capacity) ldi lcd, 0x30; Identification code for the number of units (capacity) add lcd, edinicy; rcall lcd_dat; Displays the number of units (capacity) ldi lcd, 0x2C; Display "," (capacity) rcall lcd_dat; ldi lcd, 0x30; Identification code for the number of tenths (capacity) add lcd, desyatye; rcall lcd_dat; Displays the number of tenths (capacity) rjmp uF_lcd; On uF_lcd ;----------------------- Display "2345" or "12345" lcd_1str_3: ldi lcd, 0x20; display "" (capacity) rcall lcd_dat; rjmp lcd_1str_5; On lcd_1str_5 lcd_1str_4: ldi lcd, 0x30; Identification code for the number of tens of thousands (capacity) add lcd, des_tysh; rcall lcd_dat; Displays the number of tens of thousands (capacity) lcd_1str_5: ldi lcd, 0x30; Identification code for the thousands (capacity) add lcd, tyshi; rcall lcd_dat; Displays the number of thousands (capacity) ldi lcd, 0x30; Identification code for the number of hundreds (capacity) add lcd, sotni; rcall lcd_dat; Displays the number of hundreds (capacity) ldi lcd, 0x30; Identification code for the number ten (capacity) add lcd, desyatki; rcall lcd_dat; Displays the number of ten (capacity) ldi lcd, 0x30; Identification code for the number of units (capacity) add lcd, edinicy; rcall lcd_dat; Displays the number of units (capacity) uF_lcd: ldi lcd, 0x20; display "" (capacity) rcall lcd_dat; ldi lcd, 0x75; map "u" (capacity) rcall lcd_dat; F_lcd: ldi lcd, 0x46; display "F" (capacity) rcall lcd_dat; ret; Output from subroutine ;----------------------- Sub-display of the second line LCD lcd_2str: Displaying ;----------------------- ESR ldi lcd, 0xC0; choice familiarity (early 2nd line) rcall lcd_com; clr temp; Cleaning temp cp desyatki, temp; If the value of tens of zero, the transition to lcd_2str_0 breq lcd_2str_0; otherwise further ldi lcd, 0x30; Identification code for the number of tens (ESR) add lcd, desyatki; rcall lcd_dat; Displays the number of tens (ESR) rjmp lcd_2str_1; Go to lcd_2str_1 lcd_2str_0: ldi lcd, 0x20; display "" (ESR) rcall lcd_dat; lcd_2str_1: ldi lcd, 0x30; Identification code for the number of units (ESR) add lcd, edinicy; rcall lcd_dat; Displays the number of units (ESR) ldi lcd, 0x2C; Display "," (ESR) rcall lcd_dat; ldi lcd, 0x30; Identification code for the number of tenths (ESR) add lcd, desyatye; rcall lcd_dat; Displays the number of tenths (ESR) ldi lcd, 0x30; Identification code for the number of hundredths (ESR) add lcd, sotye; rcall lcd_dat; Displays the number of hundredths (ESR) ldi lcd, 0x20; display "" (ESR) rcall lcd_dat; ldi lcd, 0x4F; display "On" (ESR) rcall lcd_dat; ldi lcd, 0x6D; map "m" (ESR) rcall lcd_dat; ret; Output from subroutine ;----------------------- Sub-display messages on LCD lcd_mess: ldi z4, 8; Record 8 z4 cpi temp, 1; comparison with a temp brne lcd_mess_2str; If str is not equal to 1, then lcd_mess_2str, otherwise further lcd_mess_1str: ldi lcd, 0x80; choice familiarity (the beginning of 1st line) rcall lcd_com; rjmp lcd_mess_0; On lcd_mess_0 lcd_mess_2str: ldi lcd, 0xC0; choice familiarity (early 2nd line) rcall lcd_com; lcd_mess_0: lpm lcd, Z +; Record lcd status byte strings from a cell with the address of Z rcall lcd_dat; dec z4; reduction z4 1 cpi z4, 0, z4 comparison with 0 brne lcd_mess_0; If z4 <> 0, then lcd_mess_0, otherwise further ret; Output from subroutine ;----------------------- Sub-display of two lines in a row on the LCD according to the tables lcd_all: ldi temp, 1, display the 1st row rcall lcd_mess; Call a display of messages ldi temp, 2; Display 2nd line rcall lcd_mess; Call a display of messages ret; Output from subroutine ;----------------------- Sub-display the number of limit pred_num: ldi lcd, 0x87; choice familiarity (end of 1st line) rcall lcd_com; ldi lcd, 0x30; Identification code for the limit add lcd, k_del; inc lcd; rcall lcd_dat; ret; Output from subroutine ;----------------------- Sub-conversion 24-bit number in binary-coded decimal Number of conversion of XL, XH, result in des_tysh, tyshi, sotni, desyatki, ; Edinicy, desyatye, sotye bin2dec: clr des_tysh; Reset tens of thousands of clr tyshi; Reset thousands clr sotni; hundreds Reset clr desyatki; Reset dozen clr edinicy; reset units clr desyatye; Reset tenths clr sotye; Reset hundredths des_tysh0: ldi z1, 0x40; Filing 1,000,000 in z1 ... z3 ldi z2, 0x42; ldi z3, 0x0F; des_tysh1: rcall c_minus_z; Subtraction 1000000 brmi des_tysh2; If the evaluation result is negative, the transition to des_tysh2 inc des_tysh; Otherwise, an increase of 1 of tens of thousands of rjmp des_tysh1; On des_tysh1 des_tysh2: rcall c_plus_z; 1000000 Adding a negative result tyshi0: ldi z1, 0xA0; Entering 100000 in z1 ... z3 ldi z2, 0x86; ldi z3, 0x01; tyshi1: rcall c_minus_z; Subtract 100 000 brmi tyshi2; If the evaluation result is negative, the transition to tyshi2 inc tyshi; Otherwise, an increase of 1 thousand numbers rjmp tyshi1; On tyshi1 tyshi2: rcall c_plus_z; addition of 100,000 to a negative result sotni0: ldi z1, 0x10; Entering 10000 z1 ... z3 ldi z2, 0x27; ldi z3, 0x00; sotni1: rcall c_minus_z; Subtract 10 000 brmi sotni2; If the evaluation result is negative, the transition to sotni2 inc sotni; Otherwise, increase by 1 the number of hundreds rjmp sotni1; On sotni1 sotni2: rcall c_plus_z; addition of 10 000 to a negative result desyatki0: ldi z1, 0xE8; Entering 1000 z1 ... z3 ldi z2, 0x03; desyatki1: rcall c_minus_z; Subtract 1000 brmi desyatki2; If the evaluation result is negative, the transition to desyatki2 inc desyatki; Otherwise, increase the number of 1 dozen rjmp desyatki1; On desyatki1 desyatki2: rcall c_plus_z; Adding 1000 to a negative result edinicy0: ldi z1, 0x64; Entry of 100 in the z1 ... z3 ldi z2, 0x00; edinicy1: rcall c_minus_z; Subtract 100 brmi edinicy2; If the evaluation result is negative, the transition to edinicy2 inc edinicy; Otherwise, increase by 1 the number of units rjmp edinicy1; On edinicy1 edinicy2: rcall c_plus_z; addition of 100 to a negative result desyatye0: ldi z1, 0x0A; Entering 10 in the z1 ... z3 desyatye1: rcall c_minus_z; Subtract 10 brmi desyatye2; If the evaluation result is negative, the transition to desyatye2 inc desyatye; Otherwise, increase by 1 the number of tenths rjmp desyatye1; On desyatye1 desyatye2: rcall c_plus_z; Adds 10 to the negative result sotye0: ldi z1, 0x01; Entering 1 in the z1 ... z3 sotye1: rcall c_minus_z; Subtract 1 brmi bin2dec1; If the evaluation result is negative, the transition to bin2dec1 inc sotye; Otherwise, increase by 1 the number of hundredths of a rjmp sotye1; On sotye1 bin2dec1: clr c1; Cleaning c1 clr c2; Cleaning c2 clr c3; Cleaning c3 ret; Output from subroutine ;----------------------- Sub multiplying 16-bit numbers, with optimization ; Run-time expense of changing the multiplier multiplies and places according to their values ; 1st day of: (c4 + c3 + c2 + c1), 2nd number: (XH + XL), Result: (c4 + c3 + c2 + c1) Cleaning ;----------------------- used registers mul16x16: clr temp; Cleaning temp clr c4; Cleaning c4 Optimization of computation time ;----------------------- mul16x16_0: cp c1, XL; Comparison of first byte numbers cpc c2, XH; Comparison of second byte integers with carry cpc c3, temp; Comparison 3rd byte integers with carry brsh mul16x16_1; If c3 + c2 + c1 is greater than or equal to XH + XL, then on mul16x16_1, push c1; otherwise continue (the change of numbers in some places on the stack) push c2; push XL; push XH; pop c2; pop c1; pop XH; pop XL; ;----------------------- Preparing for multiplication mul16x16_1: mov a1, c1; copy of the 1st byte is multiplied in a1 mov a2, c2; copy of the 2nd byte is multiplied in a1 mov a3, c3; Copying third byte is multiplied in a1 ;----------------------- Multiplication mul16x16_2: sbiw X, 1; reduction factor of 1 cp XL, temp; comparison of the result with 0 cpc XH, temp; comparison of the result to 0, in view of transfer breq mul16x16_3; If the multiplier is zero, then go to mul16x16_3, otherwise further add c1, a1; Addition c1 and a1, c1 result in adc c2, a2; Addition c2 and a2 in view of transfer, the result of c2 adc c3, a3; Addition c3 and a3 in view of transfer, result in c3 adc c4, temp; Addition c4 and temp in view of transfer, result in c4 rjmp mul16x16_2; On mul16x16_2 mul16x16_3: ret; Output from subroutine Sub-division ;----------------------- 32-bit to 16-bit number ; Dividend: (c4 + c3 + c2 + c1), splitter: (XH + XL), Result: (c3 + c2 + c1) (b3 + b2 + b1) div32_16: clr temp; Cleaning temp clr temp2; Cleaning temp2 clr XL; Cleaning XL clr XH; Cleaning XH div32_16_0: sub c1, a1; Subtraction of a1 c1 sbc c2, a2; Subtraction of a2 c2 with carry sbc c3, a3; Subtraction of a3 c3 with carry sbc c4, temp; temp Subtraction of c4 with carry brcs div32_16_1; If the evaluation result is negative, the transition to div32_16_1 adiw X, 1, adding 1 to the register pair X adc temp2, temp; Addition temp2 temp and in view of transfer, result in temp2 rjmp div32_16_0; Go to div32_16_0 div32_16_1: mov c1, XL; copy of the 1st byte of the result of XL in c1 mov c2, XH; copy of the 2nd byte of the result of XH in c2 mov c3, temp2; Copying third byte of the result from temp2 to c3 ret; Output from subroutine Sub-division ;----------------------- 32-x-bit numbers 2 through Carry Right del32_2: lsr c4; / 2 (total / 2) ror c3; ror c2; ror c1; ret; Output from subroutine Sub-division ;----------------------- 32-x-bit numbers 4 through the transfer of the right del32_4: rcall del32_2; / 2 (total / 2) rcall del32_2; / 2 (total / 4) ret; Output from subroutine Sub-division ;----------------------- 32-x-bit numbers 8 through the transfer of the right del32_8: rcall del32_2; / 2 (total / 2) rcall del32_4; / 4 (total / 8) ret; Output from subroutine Sub-division ;----------------------- 32-x-bit numbers to 32 through the transfer of the right del32_32: rcall del32_4; / 4 (total / 4) rcall del32_8; / 8 (Total / 32) ret; Output from subroutine ;----------------------- Sub-subtraction (c3 + c2 + c1) - (z3 + z2 + z1) = (c3 + c2 + c1) c_minus_z: sub c1, z1; sbc c2, z2; sbc c3, z3; ret; Output from subroutine ;----------------------- Sub Addition (c3 + c2 + c1) + (z3 + z2 + z1) = (c3 + c2 + c1) c_plus_z: add c1, z1; adc c2, z2; adc c3, z3; ret; Output from subroutine ;----------------------- Sub delay (~ 1mks at 20MHz) Number of cycles to execute (3 * N) +4 del1u: ldi temp2, d1u; d1u Record in temp2 del1u_1: dec temp2; reduction temp2 1 brne del1u_1; If the result is not 0, then go to del1u_1 ret; Output from subroutine ;----------------------- Sub delay (~ 40mks at 20MHz) Number of cycles to execute (3 * N) +4 del40u: ldi temp2, d40u; d40u Record in temp2 del40u_1: dec temp2; reduction temp2 1 brne del40u_1; If the result is not 0, then go to del40u_1 ret; Output from subroutine ;----------------------- Sub delay (~ 3ms at 20MHz) Number of cycles to execute (6 * N) +9 del3m: ldi XL, low (d3m); set a time ldi XH, high (d3m); set a time clr temp2; Cleaning temp del3m_1: sbiw X, 1; Subtract register pair X of 1 cp XL, temp2; comparison of the result with 0 cpc XH, temp2; comparison of the result to 0, in view of transfer brne del3m_1; If the result is not 0, then go to del3m_1 ret; Output from subroutine ;----------------------- Sub delay (~ 20ms at 20MHz) Number of cycles to execute (6 * N) +9 del20m: ldi XL, low (d20m); set a time ldi XH, high (d20m); set a time clr temp2; Cleaning temp del20m_1: sbiw X, 1; Subtract register pair X of 1 cp XL, temp2; comparison of the result with 0 cpc XH, temp2; comparison of the result to 0, in view of transfer brne del20m_1; If the result is not 0, then go to del20m_1 ret; Output from subroutine ;----------------------- Sub delay (~ 300ms at 20MHz) del300m: ldi temp, 15, set a time del300m_1: rcall del20m; Call a delay (~ 20ms) dec temp; Reduce temp to 1 cpi temp, 0, temp comparison with 0 brne del300m_1; If temp <> 0, then del300m_1, otherwise further ret; Output from subroutine ;----------------------- Subroutine to send commands to the LCD lcd_com: cbi PORTB, RS; Team in temp, PORTB andi temp, 0b00000011; 00,000,011 mask to clear excess ori temp, 0b00001000; alteration temp with 00.001 million (up + command strobe) rcall lcd_out; Call a lcd_out ret; Output from subroutine ;----------------------- Subroutine to send data to LCD lcd_dat: sbi PORTB, RS; Data in temp, PORTB andi temp, 0b00000011; 00,000,011 mask to clear excess ori temp, 0b00001100; logical addition to the temp 00,001,100 (up strobe + crew) rcall lcd_out; Call a lcd_out ret; Output from subroutine Sub ;----------------------- send to LCD lcd_out: rcall del1u; Call a delay (~ 1mks) sbi PORTB, E; Gate up push lcd; Saving lcd in the stack andi lcd, 0b11110000; Mask 11.11 million to clear the early nibbles or lcd, temp; logical addition to the lcd temp (up strobe + crew) out PORTB, lcd; Record command to the port rcall del1u; Call a delay (~ 1mks) cbi PORTB, E; Gate down rcall del40u; Call a delay (~ 40mks) sbi PORTB, E; Gate up pop lcd; lcd Extract from the stack swap lcd; Change nibble places andi lcd, 0b11110000; Mask 11.11 million to clear the early nibbles or lcd, temp; logical addition to the lcd temp (up strobe + crew) out PORTB, lcd; Record command to the port rcall del1u; Call a delay (~ 1mks) cbi PORTB, E; Gate down rcall del40u; Call a delay (~ 40mks) rcall del40u; Call a delay (~ 40mks) ret; Output from subroutine ;----------------------- Sub-readiness expectations of the send buffer USART_ready: sbis UCSRA, UDRE; UDRE If set, the pass mark. Team rjmp USART_ready; On USART_ready ret; Output from subroutine ;----------------------- Sub-cell recording in EEPROM ; Address recorded in the cell temp2, writable byte temp EEPROM_write: out EEAR, temp2; Transferring address EEAR out EEDR, temp; Transferring zapisyvemy bytes EEDR EEPROM_write_1: sbic EECR, EEPE; EERE If cleared, then the pass mark. Team rjmp EEPROM_write_1; On EEPROM_write_1 sbi EECR, EEMPE; Enable write in EEPROM (set EEMPE) sbi EECR, EEPE; Write the byte in the cell EEPROM (set EEPE) rcall del3m; Call a delay (~ 3ms) rcall del3m; Call a delay (~ 3ms) ret; Output from subroutine ;----------------------- Sub-reading EEPROM cell ; Address location read in temp2, temp2 read cell in the EEPROM_read: out EEAR, temp2; Transferring address EEAR EEPROM_read_1: sbic EECR, EEPE; EEPE If cleared, then the pass mark. Team rjmp EEPROM_read_1; On EEPROM_read_1 sbi EECR, EERE; location read EEPROM (set EERE) in temp2, EEDR; Transferring the read bytes into temp2 ret; Output from subroutine Sub-amendment ;----------------------- change depending on the limit predel: ldi temp, 1, Entry 1 in temp clr temp2; Cleaning temp2 cpi k_del, 0; If the amendment is a limit of 0 (clk / 1), then go to predel5 breq predel5; otherwise further cpi k_del, 1; If the amendment is a limit equal to 1 (clk / 8), then go to predel4 breq predel4; otherwise further cpi k_del, 2; If the amendment is a limit equal to 2 (clk/64), then go to predel3 breq predel3; otherwise further cpi k_del, 3; If the amendment is a limit equal to 3 (clk/256), then go to predel2 breq predel2; otherwise further ;----------------------- Division by 8 ... 1024 with the help of translations predel1: lsr z2; / 2 (total / 2) ror z1; lsr z2; / 2 (total / 4) ror z1; predel2: lsr z2; / 2 (total / 2) ror z1; lsr z2; / 2 (total / 4) ror z1; predel3: lsr z2; / 2 (total / 2) ror z1; lsr z2; / 2 (total / 4) ror z1; lsr z2; / 2 (total / 8) ror z1; predel4: lsr z2; / 2 (total / 2) ror z1; lsr z2; / 2 (total / 4) ror z1; lsr z2; / 2 (total / 8) ror z1; predel5: cp z1, temp; comparison with temp z1 cpc z2, temp2; comparison with z2 temp2 with carry brsh predel6; If z2 + z1> = 1, then predel6, otherwise further clr z1; Cleaning z1 clr z2; Cleaning z2 predel6: ret; Output from subroutine ;----------------------- Sub-display numeric string (for debugging) otlad: sbic PIND, 6; If PD6 = 0, then the pass mark. Team rjmp otlad_2; On otlad_2 rcall del3m; Call a delay (~ 3ms) sbic PIND, 6; If PD6 = 0, then the pass mark. Team rjmp otlad_2; On otlad_2 rcall lcd_both_str; Call subroutine display two numeric strings otlad_1: rcall knop_off; Call a standby button is released pop temp; cleaning the stack (because the output is not in ret) pop temp; Cleanup Stack rjmp main; On the main otlad_2: ret; Output from subroutine Sub ;----------------------- waiting button is released knop_off: sbis PIND, 6; If PD6 = 1, skip trace. Team rjmp knop_off; On knop_off rcall del3m; Call a delay (~ 3ms) sbis PIND, 6; If PD6 = 1, skip trace. Team rjmp knop_off; On knop_off ret; Output from subroutine ;----------------------- Sub-transmission from 1st to 7th byte through USART usart_1_7: rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x10; 0x10 Record in temp or des_tysh, temp; alteration des_tysh with temp, result in des_tysh out UDR, des_tysh; Transmission des_tysh in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x20; 0x20 Record in temp or tyshi, temp; alteration tyshi with temp, result in tyshi out UDR, tyshi; Transmission tyshi in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x30; 0x30 Record in temp or sotni, temp; alteration sotni with temp, result in sotni out UDR, sotni; Transmission sotni in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x40; 0x40 Record in temp or desyatki, temp; alteration desyatki with temp, result in desyatki out UDR, desyatki; Transmission desyatki in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x50; 0x50 Record in temp or edinicy, temp; alteration edinicy with temp, result in edinicy out UDR, edinicy; Transmission edinicy in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x60; 0x60 Record in temp or desyatye, temp; alteration desyatye with temp, result in desyatye out UDR, desyatye; Transmission desyatye in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0x70; 0x70 Record in temp or sotye, temp; alteration sotye with temp, result in sotye out UDR, sotye; Transmission sotye in USART rcall USART_ready; Subroutine call waiting ready transmit buffer ret; Output from subroutine ;----------------------- Sub-display one-line numeric lcd_one_str: ldi lcd, 0x4E; display "N" rcall lcd_dat; ldi lcd, 0x3A; Display "" rcall lcd_dat; ldi lcd, 0x30; Identification code for the thousands add lcd, tyshi; rcall lcd_dat; Display the thousands ldi lcd, 0x30; definition code for hundreds of add lcd, sotni; rcall lcd_dat; display of hundreds of ldi lcd, 0x30; definition code for tens of add lcd, desyatki; rcall lcd_dat; display of dozens of ldi lcd, 0x30; Identification code for the number of units add lcd, edinicy; rcall lcd_dat; Displays the number of units ldi lcd, 0x30; Identification code for the number of tenths add lcd, desyatye; rcall lcd_dat; Displays the number of tenths ldi lcd, 0x30; Identification code for the number of hundredths of a add lcd, sotye; rcall lcd_dat; Displays the number of hundredths of a ret; Output from subroutine ;----------------------- Sub display two numeric strings according to lcd_both_str: mov c1, a1; Copying from a1 to c1 mov c2, a2; Copying from a2 to c2 mov c3, a3; copy of a3 to c3 ;----------------------- Transfer Coefficient in a binary outcome BCD rcall bin2dec; Call a translation of the binary number to BCD ;----------------------- Display bias from zero to U1 "1 =" ldi lcd, 0x80; choice familiarity (the beginning of 1st line) rcall lcd_com; rcall lcd_one_str; Call a mapping from one numeric string mov c1, b1; Copying from b1 to c1 mov c2, b2; copy of b2 to c2 mov c3, b3; copy of c3 b3 in ;----------------------- Transfer Coefficient in a binary outcome BCD rcall bin2dec; Call a translation of the binary number to BCD ;----------------------- Display bias from zero to U2 "2 =" ldi lcd, 0xC0; choice familiarity (early 2nd line) rcall lcd_com; rcall lcd_one_str; Call a mapping from one numeric string ret; Output from subroutine ;----------------------- ISR for timer 1 overflow ; Since the output is not in reti, then interrupts are globally banned banned ovtim1: cli; Globally disables interrupts ldi temp, 3 Sets 3 temp cp c3, temp; comparison with temp c3 breq ovtim1_0; If c3 = 3, then at ovtim1_0, otherwise further inc c3; increase c3 1 reti; Exit ISR ovtim1_0: sbi PORTD, 0; Turn off the high current charging the capacitor sbi PORTD, 4; low current shutdown the charging sbi PORTD, 5; inclusion of the capacitor discharge ldi temp, 0b00000000; Stop timer out TCCR1B, temp; pop temp; cleaning the stack (as output by clk_down, rather than reti) pop temp; Cleanup Stack rjmp clk_down; Go to clk_down ;----------------------- Sub-process external interrupts U1 ; Since the output is not in reti, then interrupts are globally banned banned com_U1: in a1, TCNT1L; save 1 byte n1 in a2, TCNT1H; Save 2nd byte n1 mov a3, c3; Copy of c3 a3 in third byte n1 ldi temp, 0b10000000; permit an external interrupt only on PD3 (U2) out GIMSK, temp; reti; Exit ISR ;----------------------- Sub-process external interrupts by U2 com_U2: in c1, TCNT1L; save 1 byte n2 in c2, TCNT1H; Save 2nd byte n2 cli; Globally disables interrupts sbi PORTD, 0; Turn off the high current charging the capacitor sbi PORTD, 4; low current shutdown the charging sbi PORTD, 5; inclusion of the capacitor discharge ldi temp, 0b00000000; Stop timer out TCCR1B, temp; pop temp; cleaning the stack (because the output is not in reti) pop temp; Cleanup Stack ;----------------------- Check (c2 + c1) - (a2 + a1) <0 and (c2 + c1) <> 0 com_U2_0: mov b1, c1; Copy of b1 c1 (n2) mov b2, c2; Copy of b2 c2 mov b3, c3; Copy of b3 c3 sub c1, a1; Determination of the difference n2-n1 sbc c2, a2; result in c3 + c2 + c1 sbc c3, a3; cpi tok_zar, 0; tok_zar comparison with 0 breq com_U2_0_1; If tok_zar = 0, then com_U2_0_1, otherwise further com_U2_0_0: ldi temp, 255, 255 temp record rjmp com_U2_0_2; On com_U2_0_2 com_U2_0_1: ldi temp, 30, 30 record temp com_U2_0_2: clr temp2; Cleaning temp2 cp c1, temp; comparison with temp c1 cpc c2, temp2; comparison with c2 temp2 with carry cpc c3, temp2; comparison with c3 temp2 with carry brlo com_U2_1; if (c2 + c1) <30 (255), then com_U2_1, otherwise further rcall otlad; Call a display numeric string (for debugging) rjmp step1; on step1 ;----------------------- Calibration com_U2_1: cpi k_del, 0; k_del comparison with 0 breq com_U2_2; If k_del = 0, then com_U2_2, otherwise further rjmp com_U2_5; On com_U2_5 com_U2_2: cpi tok_zar, 0; tok_zar comparison with 0 breq com_U2_2_0; If tok_zar = 0, then com_U2_2_0, otherwise further clr tok_zar; Cleaning tok_zar rjmp com_U2_5; On com_U2_5 com_U2_2_0: sbic PIND, 6; If PD6 = 0, then the pass mark. Team rjmp com_U2_5; On com_U2_5 rcall del3m; Call a delay (~ 3ms) sbic PIND, 6; If PD6 = 0, then the pass mark. Team rjmp com_U2_5; On com_U2_5 Check ;----------------------- flag record in the EEPROM ldi temp2, flag; Writes temp2 address location read EEPROM rcall EEPROM_read; Call a reading of EEPROM cell cpi temp2, 100; temp2 comparison with 100 brne com_U2_3; If temp2 <> 100, on com_U2_3, otherwise further ;----------------------- Reset flag in the EEPROM write ldi temp, 0xFF; Writes 0xFF to temp ldi temp2, flag; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM ;----------------------- Display "Caliber." And "off." ldi ZL, low (Popr_off * 2); Record in ZL LSB address of a cell of the table Popr_off (alternate address) ldi ZH, high (Popr_off * 2); Record in ZH high byte address of a cell of the table Popr_off (alternate address) rcall lcd_all; Call a display of two lines in a row on the LCD according to the tables rcall knop_off; Call a standby button is released rjmp main; On the main ;----------------------- Record in EEPROM ;----------------------- Record n1 (1st and 2nd byte) com_U2_3: mov temp, a1; Copy a1 in temp ldi temp2, n1_1b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM mov temp, a2; Copy a2 in temp ldi temp2, n1_2b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM ;----------------------- Record n2 (1st and 2nd byte) mov temp, b1; Copy b1 in temp ldi temp2, n2_1b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM mov temp, b2; Copy b2 in temp ldi temp2, n2_2b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM ;----------------------- Record n2-n1 (1st and 2nd byte) mov temp, c1; Copy c1 in temp ldi temp2, n2_n1_1b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM mov temp, c2; Copy c2 in temp ldi temp2, n2_n1_2b; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM Record ;----------------------- flag record in the EEPROM ldi temp, 100, 100 is brought in temp ldi temp2, flag; Writes to EEPROM cell address temp2 rcall EEPROM_write; Call a record in the EEPROM rcall lcd_both_str; Call subroutine display two numeric strings ;----------------------- Prevent multiple entries by holding down EEPROM rcall knop_off; Call a standby button is released ldi ZL, low (Popr_on * 2); Record in ZL LSB address of a cell of the table Popr_on (alternate address) ldi ZH, high (Popr_on * 2); Record in ZH high byte address of a cell of the table Popr_on (alternate address) rcall lcd_all; Call a display of two lines in a row on the LCD according to the tables rcall del300m; Call a delay (~ 300ms) rjmp main; On the main ;----------------------- Display "Cx max" com_U2_5: ldi ZL, low (Cmn_Rmx * 2); Record in ZL LSB address of a cell of the table Smin_Rmax (alternate address) ldi ZH, high (Cmn_Rmx * 2); Record in ZH high byte address of a cell of the table Smin_Rmax (alternate address) rcall lcd_all; Call a display of two lines in a row on the LCD according to the tables inc autoff; increase autoff 1 ;----------------------- Send a message "Cx max" rcall USART_ready; Subroutine call waiting ready transmit buffer ldi temp, 0xD1; 0xD1 Record in temp out UDR, temp; transfer from temp to USART rcall USART_ready; Subroutine call waiting ready transmit buffer rjmp clk_up; on reducing the limit of measurement (for clk_up) Table ;----------------------- posts Prvt: . Db 0x43, 0x20, 0x26, 0x20, 0x45, 0x53, 0x52, 0x20; "C & ESR" . Db 0x76, 0x65, 0x72, 0x2E, 0x20, 0x31, 0x2E, 0x30; "ver. 1.0" Pred: . Db 0x52, 0x61, 0x6E, 0x67, 0x65, 0x3A, 0x20, 0x20; "Range:" . Db 0x77, 0x61, 0x69, 0x74, 0x2E, 0x2E, 0x2E, 0x20; "wait ..." Cmn_Rmx: . Db 0x43, 0x78, 0x20, 0x3C, 0x20, 0x6D, 0x69, 0x6E; "Cx max" ESRmn: . Db 0x3C, 0x30, 0x2C, 0x30, 0x31, 0x20, 0x4F, 0x6D; "<0,01 OM" ESRmx: . Db 0x3E, 0x32, 0x30, 0x2C, 0x30, 0x20, 0x4F, 0x6D; "> 20,0 OM" KZ_Cmx: . Db 0x43, 0x78, 0x20, 0x3E, 0x20, 0x6D, 0x61, 0x78; "Cx> max" . Db 0x6F, 0x72, 0x20, 0x73, 0x68, 0x6F, 0x72, 0x74; "or short" Popr_on: . Db 0x43, 0x6F, 0x72, 0x72, 0x65, 0x63, 0x2D, ​​0x20; "Correc-" . Db 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x4F, 0x4E, 0x20; "tion ON" Popr_off: . Db 0x43, 0x6F, 0x72, 0x72, 0x65, 0x63, 0x2D, ​​0x20; "Correc-" . Db 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x4F, 0x46, 0x46; "tion OFF" Bat: . Db 0x52, 0x65, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x20; "Replace" . Db 0x62, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x21; "battery!" Gdit: . Db 0x77, 0x61, 0x69, 0x74, 0x2E, 0x2E, 0x2E, 0x20; "wait ..."