📄 p08011-05.asm
字号:
;----------------------------------------------------------------------------------------------
BAT_0_ELECT:
;--------------------------if the current flag is "0FH",then the charging is ending----------------------
CMNE CURRENT_OVER_FLAG,#00H
BR !END_OF_ALL_CHARGE_0
;-------------------read the current for the control of 800mA or is reach to 200mA-----------------------
LRI ADCIS,#0001B
LDM ADCHANGE_M_0,#0000B
LDM ADCHANGE_M_1,#0000B
LDM ADCHANGE_M_2,#0000B
LDM ADCHANGE_M_3,#0000B
CALL !AD_CHANGE
;-----save the result of A/D for bat_C_0.-----
LDA ADCHANGE_M_1
LDM ADDATA_C0_0,A
LDM ADDATA_C_0,A
LDA ADCHANGE_M_2
LDM ADDATA_C0_1,A
LDM ADDATA_C_1,A
LDA ADCHANGE_M_3
LDM ADDATA_C0_2,A
LDM ADDATA_C_2,A
WDTC
;------------------judge the flag of voltage,if "0FH",than enter the mode of lasting voltage charging,
;-------------------------and if "00H",than enter the mode of lasting current charging--------------------
CMNE VOLTAGE_OVER_FLAG,#00H
BR !LASTING_VOLTAGE_CHARGE_0_1
;-----load pwm-data and save pwm-data.-----
LDA PWM_STEPS_C0_0
LDM PWM_STEPS_0,A
LDA PWM_STEPS_C0_1 ;load the pwm-steps-data to the common ram
LDM PWM_STEPS_1,A ;for the pwm deal program.
LDA PWM_STEPS_C0_2
LDM PWM_STEPS_2,A
NOP
NOP
NOP
NOP
NOP
CALL !PWM_DATA_DEAL
LDA PWM_STEPS_0
LDM PWM_STEPS_C0_0,A
LDA PWM_STEPS_1 ;save the pwm-steps-data to the pwm-setps-data of the bat_0.
LDM PWM_STEPS_C0_1,A
LDA PWM_STEPS_2
LDM PWM_STEPS_C0_2,A
;-----change the pwm_data for elect the bat_C_0 and save the new pwm-data to the special ram.-----
;-----and sent the pwm-data to the time0.-----
LRI RCR,#1000B
CLRR1 T0MR.#3
LAR DBR0
LDM PWM_CONTROL_BAT0_0L,A
LRA T0D0L
LAR DBR1
LDM PWM_CONTROL_BAT0_0H,A
LRA T0D0H
LAR DBR2
LDM PWM_CONTROL_BAT0_1L,A
LRA T0D1L
LAR DBR3
LDM PWM_CONTROL_BAT0_1H,A
LRA T0D1H
LRI RCR,#1010B
SETR1 T0MR.#3
BR !EXIT_VOLTAGE_CURRENT
;------------judge the current is not enough 200mA,if >200mA then open the pwm,if <200mA,then close the pwm---------------------------------------------------------
LASTING_VOLTAGE_CHARGE_0_1:
CMLE ADDATA_C_2,#00H
BR !VOLTAGE_0_1
BR !OVER_0_1
VOLTAGE_0_1:
CMNE ADDATA_C_2,#00H
BR !NOT_OVER_0_1
CMLE ADDATA_C_1,#00H
BR !VOLTAGE_1_1
BR !OVER_0_1
VOLTAGE_1_1:
CMNE ADDATA_C_1,#00H
BR !NOT_OVER_0_1
CMLE ADDATA_C_0,#0BH
BR !VOLTAGE_2_1
BR !OVER_0_1
VOLTAGE_2_1:
CMNE ADDATA_C_0,#0BH
BR !NOT_OVER_0_1
BR !OVER_0_1
;-----------------judge the current is enough 200mA or not,and set count the counter to 16 times---------------------
NOT_OVER_0_1:
CMNE CURRENT_OVER_COUNT,#0FH
BR !REDUCE_0_1
BR !NOT_REDUCE_0_1
;----------------the current is not enough 200mA,then increase the count----------------------------------------
REDUCE_0_1:
CLRC
ADDC CURRENT_OVER_COUNT,#01H
LDM CURRENT_OVER_COUNT,A
NOT_REDUCE_0_1:
BR !IF_OVER_0_1
;-----------------the current is >200mA,then reduce the count--------------------------
OVER_0_1:
CMNE CURRENT_OVER_COUNT,#00H
BR !INCR_0_1
BR !IF_OVER_0_1
INCR_0_1:
CLRC
SUBC CURRENT_OVER_COUNT,#01H
LDM CURRENT_OVER_COUNT,A
;--------judge the current count is reach to 16 times,if "Y", then set the current flag "0FH" and close all the pwm----------------------------
;-----------------if "N",then set the current flag "00H" and continue the lasting current charging pwm control-----------
IF_OVER_0_1:
CMNE CURRENT_OVER_COUNT,#0FH
BR !IT_IS_NOT_OVER_1
;----------------the current count is 16 times ,set the current flag to "0FH" and close all the pwm-------------------------------
LDM CURRENT_OVER_FLAG,#0FH
LRI TOPSR,#0000B
LRI PGDR,#0000B
CLRR1 R1DR.#3
BR !TEST_CURRENT_END_1
;---------------the current count is not 16 times ,set the current flag to "00H"-------------------
;----------------and continue the pwm control of lating voltage charging---------------------------
IT_IS_NOT_OVER_1:
LDM CURRENT_OVER_FLAG,#00H
TEST_CURRENT_END_1:
EXIT_VOLTAGE_CURRENT:
END_OF_ALL_CHARGE_0:
RET
;---------------------------------------------------------------------------------------------------
;-------------the function for judge that if all the pwm control charging is end or not-------------
;---------------------------------------------------------------------------------------------------
IF_ALL_CHARGE_END:
;LRI ADCIS,#0111B
;LDM ADCHANGE_M_0,#0000B
;LDM ADCHANGE_M_1,#0000B
;LDM ADCHANGE_M_2,#0000B
;LDM ADCHANGE_M_3,#0000B
;CALL !AD_CHANGE
;LDA ADCHANGE_M_1
; LDM ADDATA_V1_0,A
;LDA ADCHANGE_M_2
; LDM ADDATA_V1_1,A
;LDA ADCHANGE_M_3
;LDM ADDATA_V1_2,A
;-------------------------------------------------------------------------
CMNE CURRENT_OVER_FLAG,#0FH
BR !ALL_CHARGE_IS_NOT_END
ALL_CHARGE_IS_END:
LRI TOPSR,#0000B
LRI PGDR,#0000B
CLRR1 R1DR.#3
;----------------------------------------------------------------------------
; CMLE ADDATA_V1_2,#05H
; BR !IS_BAT_HERE
;LDM VOLTAGE_OVER_COUNT,#00H
;LDM VOLTAGE_OVER_FLAG,#00H
;LDM CURRENT_OVER_COUNT,#00H
;LDM CURRENT_OVER_FLAG,#00H
;LRI TOPSR,#0001B
; LRI PGDR,#0001B
;IS_BAT_HERE:
ALL_CHARGE_IS_NOT_END:
RET
;=======================================================================================================
;------------------------the A/D change program.--------------------------------------------------------
;=======================================================================================================
AD_CHANGE:
LDM ADCHANGE_COUNT_0,#0000B
;clear che A/D counter(16 timer) to zero.
;-----A/D change.-----
NOT_ENOUGH_16TIMES:
SETR1 ADCM.#2 ;enable the A/D change.
SETR1 ADCM.#1 ;start the A/D change.
NOP
NOP
NOP
NOP
NOP
AD_NOT_FINISHED:
WDTC
TSTR ADCM.#0
BR !ADDING_TO_TOTAL
BR !AD_NOT_FINISHED
ADDING_TO_TOTAL:
;-----stop the A/D change.-----
CLRR1 ADCM.#2 ;disable the A/D change.
CLRR1 ADCM.#1 ;stop the A/D change.
;-----add the A/D data to a total value(16 times).-----
NOP
NOP
WDTC
CLRC
LAR ADCR1
ADDC ADCHANGE_M_0,A
LDM ADCHANGE_M_0,A
LAR ADCR2
ADDC ADCHANGE_M_1,A
LDM ADCHANGE_M_1,A
LAR ADCR3
ADDC ADCHANGE_M_2,A
LDM ADCHANGE_M_2,A
ADDC ADCHANGE_M_3,#0000B
LDM ADCHANGE_M_3,A
NOP
;-----judge the A/D change is 16 times.-----
CLRC
ADDC ADCHANGE_COUNT_0,#0001B
LDM ADCHANGE_COUNT_0,A
CMNE ADCHANGE_COUNT_0,#1111B
BR !NOT_ENOUGH_16TIMES
NOP
NOP
NOP
NOP
NOP
RET
;=======================================================================================================
;-----the pwm deal program for change the pwm-data according as the current of the bat.-----------------
;=======================================================================================================
PWM_DATA_DEAL:
WDTC
CMLE ADDATA_C_2,#00H
BR !IF_NOT_ENOUGH_CURRENT_2
BR !LAGER_CURRENT
IF_NOT_ENOUGH_CURRENT_2:
CMNE ADDATA_C_2,#00H
BR !NOT_ENOUGH_CURRENT
CMLE ADDATA_C_1,#05H
BR !IF_NOT_ENOUGH_CURRENT_1
BR !LAGER_CURRENT
IF_NOT_ENOUGH_CURRENT_1:
CMNE ADDATA_C_1,#05H
BR !NOT_ENOUGH_CURRENT
CMLE ADDATA_C_0,#0EH
BR !IF_NOT_ENOUGH_CURRENT_0
BR !LAGER_CURRENT
IF_NOT_ENOUGH_CURRENT_0:
CMNE ADDATA_C_0,#0EH
BR !NOT_ENOUGH_CURRENT
BR !GET_PWM_DATAS
NOT_ENOUGH_CURRENT:
CLRC
ADDC PWM_STEPS_0,#01H
LDM PWM_STEPS_0,A
ADDC PWM_STEPS_1,#0H
LDM PWM_STEPS_1,A
ADDC PWM_STEPS_2,#0H
LDM PWM_STEPS_2,A
BR !GET_PWM_DATAS
LAGER_CURRENT:
CLRC
SUBC PWM_STEPS_0,#01H
LDM PWM_STEPS_0,A
SUBC PWM_STEPS_1,#0H
LDM PWM_STEPS_1,A
SUBC PWM_STEPS_2,#0H
LDM PWM_STEPS_2,A
BR !GET_PWM_DATAS
GET_PWM_DATAS:
CMLE PWM_STEPS_2,#01H
BR !GET_PWM_DATAS_1
LDM PWM_STEPS_0,#0FH
LDM PWM_STEPS_1,#0FH
LDM PWM_STEPS_2,#01H
GET_PWM_DATAS_1:
NOP
NOP
WDTC
LRI ABR0,#<TABPWM
LRI ABR1,#>TABPWM
LRI ABR2,#[TABPWM
LRI ABR3,#]TABPWM
LDA PWM_STEPS_0
CLRC
ADDC ABR0,A
LDA PWM_STEPS_1
ADDC ABR1,A
LDA PWM_STEPS_2
ADDC ABR2,A
ADDC ABR3,#0H
LDW @ABR
NOP
NOP
NOP
RET
;========================================================================================================
;----------the pwm deal program for change the pwm-data according as the voltage of the bat.-------------
;========================================================================================================
PWM_DATA_DEAL_1:
WDTC
CMLE ADDATA_V1_2,#03H
BR !IF_NOT_ENOUGH_CURRENT_2_1
BR !LAGER_CURRENT_1
IF_NOT_ENOUGH_CURRENT_2_1:
CMNE ADDATA_V1_2,#03H
BR !NOT_ENOUGH_CURRENT_1
CMLE ADDATA_V1_1,#08H
BR !IF_NOT_ENOUGH_CURRENT_1_1
BR !LAGER_CURRENT_1
IF_NOT_ENOUGH_CURRENT_1_1:
CMNE ADDATA_V1_1,#08H
BR !NOT_ENOUGH_CURRENT_1
CMLE ADDATA_V1_0,#03H
BR !IF_NOT_ENOUGH_CURRENT_0_1
BR !LAGER_CURRENT_1
IF_NOT_ENOUGH_CURRENT_0_1:
CMNE ADDATA_V1_0,#03H
BR !NOT_ENOUGH_CURRENT_1
BR !_GET_PWM_DATAS_1
NOT_ENOUGH_CURRENT_1:
CLRC
ADDC PWM_STEPS_0,#01H
LDM PWM_STEPS_0,A
ADDC PWM_STEPS_1,#0H
LDM PWM_STEPS_1,A
ADDC PWM_STEPS_2,#0H
LDM PWM_STEPS_2,A
BR !_GET_PWM_DATAS_1
LAGER_CURRENT_1:
CLRC
SUBC PWM_STEPS_0,#01H
LDM PWM_STEPS_0,A
SUBC PWM_STEPS_1,#0H
LDM PWM_STEPS_1,A
SUBC PWM_STEPS_2,#0H
LDM PWM_STEPS_2,A
BR !_GET_PWM_DATAS_1
_GET_PWM_DATAS_1:
CMLE PWM_STEPS_2,#01H
BR !GET_PWM_DATAS_1_1
LDM PWM_STEPS_0,#0FH
LDM PWM_STEPS_1,#0FH
LDM PWM_STEPS_2,#01H
GET_PWM_DATAS_1_1:
NOP
NOP
WDTC
LRI ABR0,#<TABPWM
LRI ABR1,#>TABPWM
LRI ABR2,#[TABPWM
LRI ABR3,#]TABPWM
LDA PWM_STEPS_0
CLRC
ADDC ABR0,A
LDA PWM_STEPS_1
ADDC ABR1,A
LDA PWM_STEPS_2
ADDC ABR2,A
ADDC ABR3,#0H
LDW @ABR
NOP
NOP
NOP
RET
;=======================================================================================================
;----------------time delay at 2~3ms.-------------------------------------------------------------------
;=======================================================================================================
DELAY:
LDM DELAY2,#0000B
DELAY_0:
LDM DELAY0,#0000B
LDM DELAY1,#0000B
DELAY_1:
WDTC
NOP
CLRC
ADDC DELAY0,#0001B
LDM DELAY0,A
ADDC DELAY1,#0000B
LDM DELAY1,A
TSTC
BR !DELAY_2
BR !DELAY_1
DELAY_2:
CLRC
ADDC DELAY2,#0001B
LDM DELAY2,A
CMNE DELAY2,#0010B
BR !DELAY_0
NOP
NOP
RET
;=======================================================================================================
;----------------------------time delay at 2~3s.--------------------------------------------------------
;=======================================================================================================
_DELAY:
LDM DELAY2,#0000B
_DELAY_0:
LDM DELAY0,#0000B
LDM DELAY1,#0000B
LDM DELAY3,#0000B
LDM DELAY4,#0000B
_DELAY_1:
WDTC
NOP
CLRC
ADDC DELAY0,#0001B
LDM DELAY0,A
ADDC DELAY1,#0000B
LDM DELAY1,A
ADDC DELAY3,#0000B
LDM DELAY3,A
ADDC DELAY4,#0000B
LDM DELAY4,A
TSTC
BR !_DELAY_2
BR !_DELAY_1
_DELAY_2:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -