ESET:
RCALL PORTS_INIT
RCALL CLR_MEM
RCALL INTERRUPT_INIT
RCALL ADC_INIT
RCALL I2C_DS3231_START_INIT
RCALL TIMER_INIT_0
LDI REG16,1
STS MENU_Z,REG16
CLR REG21
CLR REG16
RCALL BUTTON_WAS_PRESSED
SEI
MAIN:
RCALL KEYBOARD_PORTx
RCALL CHK_MENU
RCALL ADC_BAT_FILTER_CHK
RCALL HALT_FUNCTION
RJMP MAIN
;------------------------------------------
;
;------------------------------------------
HALT_FUNCTION:
LDS REG16,KEY_CODE
CPI REG16,'N'
BRNE NEED_ON
LDS REG16,HALT_FLIP_REG
TST REG16
BREQ HALT_FUNCTION_OUT
CBI PORTC,2 ; ;
CBI PORTB,2 ;
HALT_FUNCTION_CLR:
LDI REG16,0xBC
STS HALT_FLIP_BYTE,REG16
LDI REG16,0x0C
STS HALT_FLIP_BYTE+1,REG16
CLR REG16
STS HALT_FLIP_REG,REG16
HALT_FUNCTION_OUT:
RET
NEED_ON:
SBI PORTC,2 ;
SBI PORTB,2 ;
RJMP HALT_FUNCTION_CLR
HALT_INCREMENT:
LDS REG16,HALT_FLIP_BYTE
LDS REG17,HALT_FLIP_BYTE+1
SUBI REG16,1
SBCI REG17,0
STS HALT_FLIP_BYTE,REG16
STS HALT_FLIP_BYTE+1,REG17
TST REG16
BRNE NO_HALT
TST REG17
BRNE NO_HALT
LDI REG16,1
STS HALT_FLIP_REG,REG16
NO_HALT:
RET
;------------------------------------------
;
;------------------------------------------
;-----------------------------------------------
;
;-----------------------------------------------
MENU_ERR_CLR: ; - +
CLR REG16
STS MENU_X,REG16
STS MENU_Y,REG16
STS MENU_Z,REG16
RET
TIME_MENU_LOGIC:
RJMP TIME_MENU_LOGIC_L ;
DATE_MENU_LOGIC:
RJMP DATE_MENU_LOGIC_L ;
TEMPERATURE_MENU_LOGIC:
RJMP TEMPERATURE_MENU_LOGIC_L ;
INTERNAL_LOGIC: ; +
LDS REG16,MENU_X
CPI REG16,0
BREQ TIME_MENU_LOGIC
CPI REG16,1
BREQ DATE_MENU_LOGIC
CPI REG16,2
BREQ TEMPERATURE_MENU_LOGIC
CPI REG16,3
BRSH MENU_ERR_CLR
;-----------------------------------------------
; Y
;-----------------------------------------------
TIME_MENU_LOGIC_L: ; , 0, 1, 2
LDS REG16,MENU_Y
CPI REG16,0
BREQ TIME_MENU_LOGIC_STAGE_Y0_L
CPI REG16,1
BREQ TIME_MENU_LOGIC_STAGE_Y1_L
CPI REG16,2
BREQ TIME_MENU_LOGIC_STAGE_Y2_L
CLR REG16
STS MENU_Y,REG16
RET
TIME_MENU_LOGIC_STAGE_Y0_L: ; , 0, , , - 1
RCALL LOGIC_VECTOR_SUPERVISOR_LEVEL_Y0
RET
TIME_MENU_LOGIC_STAGE_Y1_L: ; X0,-1,Z0
RCALL LOGIC_VECTOR_SUPERVISOR_LEVEL_Y1
RET
TIME_MENU_LOGIC_STAGE_Y2_L:
LDS REG16,KEY_CODE
CPI REG16,'R'
BRNE TMLSY2L_L
LDS REG16,SUB_MENU_6
CPI REG16,0
BRNE INC_SEC_TEN
RJMP INC_SET_SEC_ONE
INC_SEC_TEN:
CPI REG16,1
BRNE INC_MIN_ONE
RJMP INC_SET_SEC_TEN
INC_MIN_ONE:
CPI REG16,2
BRNE INC_MIN_TEN
RJMP INC_SET_MIN_ONE
INC_MIN_TEN:
CPI REG16,3
BRNE INC_HOUR_ONE
RJMP INC_SET_MIN_TEN
INC_HOUR_ONE:
CPI REG16,4
BRNE INC_HOUR_TEN
RJMP INC_SET_HOUR_ONE
INC_HOUR_TEN:
CPI REG16,5
BRNE TIME_INC_ERR
RJMP INC_SET_HOUR_TEN
RET
TIME_INC_ERR:
RET
TMLSY2L_L:
LDS REG16,KEY_CODE
CPI REG16,'L'
BRNE TMLSY2L_C
LDS REG16,SUB_MENU_6
CPI REG16,0
BRNE DEC_SEC_TEN
RJMP DEC_SET_SEC_ONE
DEC_SEC_TEN:
CPI REG16,1
BRNE DEC_MIN_ONE
RJMP DEC_SET_SEC_TEN
DEC_MIN_ONE:
CPI REG16,2
BRNE DEC_MIN_TEN
RJMP DEC_SET_MIN_ONE
DEC_MIN_TEN:
CPI REG16,3
BRNE DEC_HOUR_ONE
RJMP DEC_SET_MIN_TEN
DEC_HOUR_ONE:
CPI REG16,4
BRNE DEC_HOUR_TEN
RJMP DEC_SET_HOUR_ONE
DEC_HOUR_TEN:
CPI REG16,5
BRNE TIME_DEC_ERR
RJMP DEC_SET_HOUR_TEN
RET
TIME_DEC_ERR:
RET
TMLSY2L_C:
LDS REG16,KEY_CODE
CPI REG16,'C'
BRNE TMLSY2L_OUT
LDI REG16,1
STS MENU_Y,REG16
CLR REG16
STS KEY_CODE,REG16
TMLSY2L_OUT:
RET
CLT_KEY:
CLR REG16
STS KEY_CODE,REG16
RET
;-----------------------------------------------
;
;-----------------------------------------------
INC_SET_SEC_ONE:
LDS REG16,T_SECONDS
MOV REG17,REG16
RCALL INC_9_T
STS T_SECONDS,REG16
RJMP CLT_KEY
INC_SET_SEC_TEN:
LDS REG16,T_SECONDS
MOV REG17,REG16
RCALL INC_5_T
STS T_SECONDS,REG16
RJMP CLT_KEY
INC_SET_MIN_ONE:
LDS REG16,T_MINUTES
MOV REG17,REG16
RCALL INC_9_T
STS T_MINUTES,REG16
RJMP CLT_KEY
INC_SET_MIN_TEN:
LDS REG16,T_MINUTES
MOV REG17,REG16
RCALL INC_5_T
STS T_MINUTES,REG16
RJMP CLT_KEY
INC_SET_HOUR_ONE:
LDS REG16,T_HOURS
STS TIME_BUFFER,REG16
RCALL INC_3_9_T
LDS REG16,TIME_BUFFER
STS T_HOURS,REG16
RJMP CLT_KEY
INC_SET_HOUR_TEN:
LDS REG16,T_HOURS
STS TIME_BUFFER,REG16
RCALL INC_2_T
LDS REG16,TIME_BUFFER
STS T_HOURS,REG16
RJMP CLT_KEY
DEC_SET_SEC_ONE:
LDS REG16,T_SECONDS
MOV REG17,REG16
RCALL DEC_9_T
STS T_SECONDS,REG16
RJMP CLT_KEY
DEC_SET_SEC_TEN:
LDS REG16,T_SECONDS
MOV REG17,REG16
RCALL DEC_5_T
STS T_SECONDS,REG16
RJMP CLT_KEY
DEC_SET_MIN_ONE:
LDS REG16,T_MINUTES
MOV REG17,REG16
RCALL DEC_9_T
STS T_MINUTES,REG16
RJMP CLT_KEY
DEC_SET_MIN_TEN:
LDS REG16,T_MINUTES
MOV REG17,REG16
RCALL DEC_5_T
STS T_MINUTES,REG16
RJMP CLT_KEY
DEC_SET_HOUR_ONE:
LDS REG16,T_HOURS
STS TIME_BUFFER,REG16
RCALL DEC_3_9_T
LDS REG16,TIME_BUFFER
STS T_HOURS,REG16
RJMP CLT_KEY
DEC_SET_HOUR_TEN:
LDS REG16,T_HOURS
STS TIME_BUFFER,REG16
RCALL DEC_2_T
LDS REG16,TIME_BUFFER
STS T_HOURS,REG16
RJMP CLT_KEY
INC_9_T:
ANDI REG16,0b00001111
CPI REG16,0x09
BREQ OVERLAP_INC_SET_SEC_ONE
INC REG16
RJMP INC_SET_SEC_ONE_SAVE
OVERLAP_INC_SET_SEC_ONE:
CLR REG16
INC_SET_SEC_ONE_SAVE:
ANDI REG17,0b11110000
ADD REG16,REG17
RET
INC_5_T:
ANDI REG16,0b11110000
CPI REG16,0x50
BREQ OVERLAP_INC_SET_SEC_TEN
SUBI REG16,-16
RJMP INC_SET_SEC_TEN_SAVE
OVERLAP_INC_SET_SEC_TEN:
CLR REG16
INC_SET_SEC_TEN_SAVE:
ANDI REG17,0b00001111
ADD REG16,REG17
RET
INC_3_9_T:
LDS REG16,TIME_BUFFER
ANDI REG16,0b11110000
CPI REG16,0x20
BRLO HOURS_MAX_INC_X9
LDS REG16,TIME_BUFFER
ANDI REG16,0b00001111
CPI REG16,0x03
BREQ OVERLAP_INC_SET_HOUR_ONE
INC REG16
RJMP INC_SET_HOUR_ONE_SAVE
HOURS_MAX_INC_X9:
LDS REG16,TIME_BUFFER
ANDI REG16,0b00001111
CPI REG16,0x09
BREQ OVERLAP_INC_SET_HOUR_ONE
INC REG16
RJMP INC_SET_HOUR_ONE_SAVE
OVERLAP_INC_SET_HOUR_ONE:
CLR REG16
INC_SET_HOUR_ONE_SAVE:
LDS REG17,TIME_BUFFER
ANDI REG17,0b11110000
ADD REG16,REG17
STS TIME_BUFFER,REG16
RET
INC_2_T:
LDS REG16,TIME_BUFFER
ANDI REG16,0b11110000
CPI REG16,0x20
BRSH OVERLAP_INC_SET_HOUR_TEN
SUBI REG16,-16
LDS REG17,TIME_BUFFER
ANDI REG17,0b11110000
CPI REG17,0x10
BREQ HOURS_INC_CLR
RJMP INC_SET_HOUR_TEN_SAVE
HOURS_INC_CLR:
LDS REG17,TIME_BUFFER
ANDI REG17,0b00001111
CPI REG17,0x04
BRSH SET_MAX_23_TOP
RJMP INC_SET_HOUR_TEN_SAVE
OVERLAP_INC_SET_HOUR_TEN:
CLR REG16
INC_SET_HOUR_TEN_SAVE:
LDS REG17,TIME_BUFFER
ANDI REG17,0b00001111
ADD REG16,REG17
STS TIME_BUFFER,REG16
RJMP CLT_KEY
SET_MAX_23_TOP:
LDI REG16,0x23
STS TIME_BUFFER,REG16
RET
DEC_9_T:
ANDI REG16,0b00001111
TST REG16
BREQ OVERLAP_DEC_SET_SEC_ONE
DEC REG16
RJMP DEC_SET_SEC_ONE_SAVE
OVERLAP_DEC_SET_SEC_ONE:
LDI REG16,0x09
DEC_SET_SEC_ONE_SAVE:
ANDI REG17,0b11110000
ADD REG16,REG17
RET
DEC_5_T:
ANDI REG16,0b11110000
TST REG16
BREQ OVERLAP_DEC_SET_SEC_TEN
SUBI REG16,0b00010000
RJMP DEC_SET_SEC_TEN_SAVE
OVERLAP_DEC_SET_SEC_TEN:
LDI REG16,0x50
DEC_SET_SEC_TEN_SAVE:
ANDI REG17,0b00001111
ADD REG16,REG17
RET
DEC_3_9_T:
LDS REG16,TIME_BUFFER
ANDI REG16,0b00001111
TST REG16
BREQ OVERLAP_DEC_SET_HOUR_ONE
DEC REG16
RJMP DEC_SET_HOUR_ONE_SAVE
OVERLAP_DEC_SET_HOUR_ONE:
LDS REG16,TIME_BUFFER
ANDI REG16,0b11110000
CPI REG16,0x20
BRSH HOURS_MAX_X3
LDI REG16,0x09
RJMP DEC_SET_HOUR_ONE_SAVE
HOURS_MAX_X3:
LDI REG16,0x03
DEC_SET_HOUR_ONE_SAVE:
LDS REG17,TIME_BUFFER
ANDI REG17,0b11110000
ADD REG16,REG17
STS TIME_BUFFER,REG16
RET
DEC_2_T:
LDS REG16,TIME_BUFFER
ANDI REG16,0b11110000
TST REG16
BREQ OVERLAP_DEC_SET_HOUR_TEN
SUBI REG16,0b00010000
RJMP DEC_SET_HOUR_TEN_SAVE
OVERLAP_DEC_SET_HOUR_TEN:
LDS REG16,TIME_BUFFER
ANDI REG16,0b00001111
CPI REG16,0x04
BRSH DEC_SET_HOUR_TEN_RESAVE
LDI REG16,0x20
DEC_SET_HOUR_TEN_SAVE:
LDS REG17,TIME_BUFFER
ANDI REG17,0b00001111
ADD REG16,REG17
STS TIME_BUFFER,REG16
RJMP CLT_KEY
DEC_SET_HOUR_TEN_RESAVE:
LDI REG16,0x23
STS TIME_BUFFER,REG16
RET
;-----------------------------------------------
; Y
;-----------------------------------------------
DATE_MENU_LOGIC_L:
LDS REG16,MENU_Y
CPI REG16,0
BREQ DATE_MENU_LOGIC_STAGE_Y0_L
CPI REG16,1
BREQ DATE_MENU_LOGIC_STAGE_Y1_L
CPI REG16,2
BREQ DATE_MENU_LOGIC_STAGE_Y2_L
CLR REG16
STS MENU_Y,REG16
RET
DATE_MENU_LOGIC_STAGE_Y0_L:
RCALL LOGIC_VECTOR_SUPERVISOR_LEVEL_Y0
RET
DATE_MENU_LOGIC_STAGE_Y1_L:
RCALL LOGIC_VECTOR_SUPERVISOR_LEVEL_Y1
RET
DATE_MENU_LOGIC_STAGE_Y2_L:
LDS REG16,KEY_CODE
CPI REG16,'R'
BRNE DATE_SET_L
LDS REG16,SUB_MENU_6
CPI REG16,0
BREQ INC_DATE_YEAR
CPI REG16,1
BREQ INC_DATE_YEAR
CPI REG16,2
BREQ INC_DATE_MONTH
CPI REG16,3
BREQ INC_DATE_MONTH
CPI REG16,4
BREQ INC_DATE_DAY
CPI REG16,5
BREQ INC_DATE_DAY
RET
INC_DATE_YEAR:
RJMP INC_DATE_Y
INC_DATE_MONTH:
RJMP INC_DATE_M
INC_DATE_DAY:
RJMP INC_DATE_D
DATE_SET_L:
LDS REG16,KEY_CODE
CPI REG16,'L'
BRNE DATE_SET_C
LDS REG16,SUB_MENU_6
CPI REG16,0
BREQ DEC_DATE_YEAR
CPI REG16,1
BREQ DEC_DATE_YEAR
CPI REG16,2
BREQ DEC_DATE_MONTH
CPI REG16,3
BREQ DEC_DATE_MONTH
CPI REG16,4
BREQ DEC_DATE_DAY
CPI REG16,5
BREQ DEC_DATE_DAY
RET
DEC_DATE_YEAR:
RJMP DEC_DATE_Y
DEC_DATE_MONTH:
RJMP DEC_DATE_M
DEC_DATE_DAY:
RJMP DEC_DATE_D
DATE_SET_C:
RJMP TMLSY2L_C
;------------------------------------------------
;
;------------------------------------------------
INC_DATE_Y:
LDS REG16,D_YEAR
MOV REG17,REG16
CPI REG17,0x99
BRSH DATE_Y_CLR
ANDI REG17,0b00001111
CPI REG17,0x09
BRSH INC_AND_CLR
INC REG17
RJMP SIMPLE_INC
INC_AND_CLR:
LDI REG17,0x10
SIMPLE_INC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_YEAR,REG16
RJMP INC_DATE_Y_OUT
DATE_Y_CLR:
CLR REG16
STS D_YEAR,REG16
INC_DATE_Y_OUT:
RCALL DAY_LIMIT_COMPARE
RJMP CLT_KEY
INC_DATE_M:
LDS REG16,D_MONTHS
MOV REG17,REG16
CPI REG17,0x12
BRSH DATE_M_CLR
ANDI REG17,0b00001111
CPI REG17,0x09
BRSH INC_M
INC REG17
RJMP SIMPLE_M_INC
INC_M:
LDI REG17,0x10
SIMPLE_M_INC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_MONTHS,REG16
RJMP INC_DATE_M_OUT
DATE_M_CLR:
LDI REG16,1
STS D_MONTHS,REG16
INC_DATE_M_OUT:
RCALL DAY_LIMIT_COMPARE
RJMP CLT_KEY
INC_DATE_D:
RCALL DAY_LIMIT_COMPARE
LDS REG16,D_DAY
MOV REG17,REG16
LDS REG18,DATE_SET_LIMIT
CP REG17,REG18
BRSH DATE_D_CLR
ANDI REG17,0b00001111
CPI REG17,0x09
BRSH INC_D
INC REG17
RJMP SIMPLE_D_INC
INC_D:
LDI REG17,0x10
SIMPLE_D_INC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_DAY,REG16
RJMP INC_DATE_D_OUT
DATE_D_CLR:
LDI REG16,1
STS D_DAY,REG16
INC_DATE_D_OUT:
RJMP CLT_KEY
DEC_DATE_Y:
LDS REG16,D_YEAR
MOV REG17,REG16
CPI REG17,0x00
BREQ DATE_Y_TOP
ANDI REG17,0b00001111
CPI REG17,0x00
BREQ DEC_AND_CLR
DEC REG17
RJMP SIMPLE_DEC
DEC_AND_CLR:
LDI REG17,0x09
SUBI REG16,0x10
SIMPLE_DEC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_YEAR,REG16
RJMP DEC_DATE_Y_OUT
DATE_Y_TOP:
LDI REG16,0x99
STS D_YEAR,REG16
DEC_DATE_Y_OUT:
RCALL DAY_LIMIT_COMPARE
RJMP CLT_KEY
DEC_DATE_M:
LDS REG16,D_MONTHS
MOV REG17,REG16
CPI REG17,0x01
BREQ DATE_M_TOP
ANDI REG17,0b00001111
CPI REG17,0x00
BREQ DEC_M
DEC REG17
RJMP SIMPLE_M_DEC
DEC_M:
LDI REG17,0x09
SUBI REG16,0x10
SIMPLE_M_DEC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_MONTHS,REG16
RJMP DEC_DATE_M_OUT
DATE_M_TOP:
LDI REG16,0x12
STS D_MONTHS,REG16
DEC_DATE_M_OUT:
RCALL DAY_LIMIT_COMPARE
RJMP CLT_KEY
DEC_DATE_D:
RCALL DAY_LIMIT_COMPARE
LDS REG16,D_DAY
MOV REG17,REG16
CPI REG17,0x01
BREQ DATE_D_TOP
ANDI REG17,0b00001111
CPI REG17,0x00
BREQ DEC_D
DEC REG17
RJMP SIMPLE_D_DEC
DEC_D:
LDI REG17,0x09
SUBI REG16,0x10
SIMPLE_D_DEC:
ANDI REG16,0b11110000
ADD REG16,REG17
STS D_DAY,REG16
RJMP DEC_DATE_D_OUT
DATE_D_TOP:
LDS REG16,DATE_SET_LIMIT
STS D_DAY,REG16
DEC_DATE_D_OUT:
RJMP CLT_KEY
DAY_LIMIT_COMPARE:
LDS REG16,D_MONTHS
ANDI REG16,0b01111111
CPI REG16,0x02
BREQ DAY_4_Y
CPI REG16,0x04
BREQ DAY_30
CPI REG16,0x06
BREQ DAY_30
CPI REG16,0x09
BREQ DAY_30
CPI REG16,0x11
BREQ DAY_30
LDI REG16,0x31
STS DATE_SET_LIMIT,REG16
RJMP DAY_LIMIT_OUT
DAY_30:
LDI REG16,0x30
STS DATE_SET_LIMIT,REG16
RJMP DAY_LIMIT_OUT
DAY_4_Y:
LDS REG16,D_YEAR
CPI REG16,0x00
BREQ DAY_29
CPI REG16,0x04
BREQ DAY_29
CPI REG16,0x08
BREQ DAY_29
CPI REG16,0x12
BREQ DAY_29
CPI REG16,0x16
BREQ DAY_29
CPI REG16,0x20
BREQ DAY_29
CPI REG16,0x24
BREQ DAY_29
CPI REG16,0x28
BREQ DAY_29
CPI REG16,0x32
BREQ DAY_29
CPI REG16,0x36
BREQ DAY_29
CPI REG16,0x40
BREQ DAY_29
CPI REG16,0x44
BREQ DAY_29
CPI REG16,0x48
BREQ DAY_29
CPI REG16,0x52
BREQ DAY_29
CPI REG16,0x56
BREQ DAY_29
CPI REG16,0x60
BREQ DAY_29
CPI REG16,0x64
BREQ DAY_29
CPI REG16,0x68
BREQ DAY_29
CPI REG16,0x72
BREQ DAY_29
CPI REG16,0x76
BREQ DAY_29
CPI REG16,0x80
BREQ DAY_29
CPI REG16,0x84
BREQ DAY_29
CPI REG16,0x88
BREQ DAY_29
CPI REG16,0x92
BREQ DAY_29
CPI REG16,0x96
BREQ DAY_29
DAY_28:
LDI REG16,0x28
STS DATE_SET_LIMIT,REG16
RJMP DAY_LIMIT_OUT
DAY_29:
LDI REG16,0x29
STS DATE_SET_LIMIT,REG16
DAY_LIMIT_OUT:
LDS REG17,D_DAY
CP REG17,REG16
BRSH GET_TOP_DAY
JUST_OUT:
RET
GET_TOP_DAY:
LDS REG16,DATE_SET_LIMIT
STS D_DAY,REG16
RET
;-----------------------------------------------
; Y
;-----------------------------------------------
TEMPERATURE_MENU_LOGIC_L: ; -0 -1
LDS REG16,MENU_Y
CPI REG16,0
BREQ TEMPERATURE_MENU_LOGIC_STAGE_Y0
CPI REG16,1
BREQ TEMPERATURE_MENU_LOGIC_STAGE_Y1
CLR REG16
STS MENU_Y,REG16
RET
TEMPERATURE_MENU_LOGIC_STAGE_Y0: ; -0
RCALL LOGIC_VECTOR_SUPERVISOR_LEVEL_Y0
RET
TEMPERATURE_MENU_LOGIC_STAGE_Y1: ; -1
LDS REG16,KEY_CODE
CPI REG16,'L'
BRNE SET_T_R
RCALL DECREMENT_TIC_SPEED
RCALL HOLD_CLR
RET
SET_T_R:
CPI REG16,'R'
BRNE SET_T_C
RCALL INCREMENT_TIC_SPEED
RCALL HOLD_CLR
RET
SET_T_C:
RCALL OK_HOLD
CLR REG16
STS OK_FLIP,REG16
INTERNAL_LOGIC_OUT:
RET
;-----------------------------------------------
;
;-----------------------------------------------
DECREMENT_TIC_SPEED: ;
LDS REG16,AGING_OFFSET
MOV REG17,REG16
ANDI REG17,0b10000000
CPI REG17,0b10000000
BREQ MINUS_AGING
TST REG16
BREQ DEC_ZERO
DEC REG16
STS AGING_OFFSET,REG16
RJMP DECREMENT_AGING_OUT
DEC_ZERO:
LDI REG16,0b10000001
STS AGING_OFFSET,REG16
RJMP DECREMENT_AGING_OUT
MINUS_AGING:
ANDI REG16,0b01111111
CPI REG16,99
BRSH DECREMENT_AGING_OUT
INC REG16
LDI REG17,0b10000000
ADD REG16,REG17
STS AGING_OFFSET,REG16
DECREMENT_AGING_OUT:
CLR REG16
STS KEY_CODE,REG16
RET
INCREMENT_TIC_SPEED: ;
LDS REG16,AGING_OFFSET
MOV REG17,REG16
ANDI REG17,0b10000000
CPI REG17,0b10000000
BREQ PLUS_AGING
CPI REG16,99
BRSH INCREMENT_AGING_OUT
INC REG16
STS AGING_OFFSET,REG16
RJMP INCREMENT_AGING_OUT
INC_ZERO:
CLR REG16
STS AGING_OFFSET,REG16
RJMP INCREMENT_AGING_OUT
PLUS_AGING:
CPI REG16,0b10000001
BREQ INC_ZERO
ANDI REG16,0b01111111
DEC REG16
LDI REG17,0b10000000
ADD REG16,REG17
STS AGING_OFFSET,REG16
INCREMENT_AGING_OUT:
CLR REG16
STS KEY_CODE,REG16
RET
;-----------------------------------------------
;
;-----------------------------------------------
ADC_BAT_FILTER_CHK: ;
LDS REG16,ADC_VAL_FLIP
TST REG16
BREQ ADC_BAT_FILTER_OUT
LDS REG16,ADC_BAT_CYCLES_FILTER
TST REG16
BREQ START_FILTER
LDS REG16,ADC_BAT_CYCLES_FILTER
DEC REG16
STS ADC_BAT_CYCLES_FILTER,REG16
LDS REG16,ADC_BAT_VALUE_TEMP
CLR REG17
LDS REG18,ADC_BAT_RES_FILTER
LDS REG19,ADC_BAT_RES_FILTER+1
ADD REG18,REG16
ADC REG19,REG17
STS ADC_BAT_RES_FILTER,REG18
STS ADC_BAT_RES_FILTER+1,REG19
RJMP CLR_FLIP
START_FILTER:
LDI REG18,7
LDS REG16,ADC_BAT_RES_FILTER
LDS REG17,ADC_BAT_RES_FILTER+1
FILTER_LOOP:
ROR REG17
ROR REG16
CLC
DEC REG18
BRNE FILTER_LOOP
STS ADC_BAT_RES,REG16
CLR REG16
STS ADC_BAT_RES_FILTER,REG16
STS ADC_BAT_RES_FILTER+1,REG16
LDI REG16,128
STS ADC_BAT_CYCLES_FILTER,REG16
CLR_FLIP:
CLR REG16
STS ADC_VAL_FLIP,REG16
...
This file has been truncated, please download it to see its full contents.
Comments