các pro ơi giúp em với.
em có đoạn code asm cần chuyển qua dạng flowchart algorithm.nhưng em đọc code k hiểu chức năng
các bác làm ơn bỏ chút thời gian giúp em với. em đang cần gấp mail của em đây : single.dkny@gmail.com (rep cho em sớm nhé.)
LIST P=16F72, F=INHX8M
include "P16F72.inc"
__config _HS_OSC & _WDT_ON & _PWRTE_ON & _CP_OFF
W_TEMP equ 0x20
BATTV equ 0x4D
AD_RESULT equ 0x33
SEL_CHANEL equ 0x32
goto init
nop
nop
nop
goto isr
nop
nop
nop
table ADDWF PCL , F
RETLW .0
RETLW .6
RETLW .13
RETLW .19
RETLW .25
RETLW .31
RETLW .37
RETLW .43
RETLW .49
RETLW .55
RETLW .60
RETLW .66
RETLW .71
RETLW .76
RETLW .81
RETLW .86
RETLW .91
RETLW .95
RETLW .99
RETLW .103
RETLW .106
RETLW .110
RETLW .113
RETLW .116
RETLW .118
RETLW .121
RETLW .122
RETLW .124
RETLW .126
RETLW .127
RETLW .127
RETLW .128
RETLW .128
RETLW .128
RETLW .127
RETLW .127
RETLW .126
RETLW .124
RETLW .122
RETLW .121
RETLW .118
RETLW .116
RETLW .113
RETLW .110
RETLW .106
RETLW .103
RETLW .99
RETLW .95
RETLW .91
RETLW .86
RETLW .81
RETLW .76
RETLW .71
RETLW .66
RETLW .60
RETLW .55
RETLW .49
RETLW .43
RETLW .37
RETLW .31
RETLW .25
RETLW .19
RETLW .13
RETLW .6
RETLW .0
init clrf STATUS
clrf PORTC
clrf PORTB
bcf STATUS,RP1
bsf STATUS,RP0 ; switch to bank 1
movlw b'11000111'
movwf OPTION_REG
movlw b'111111'
movwf TRISA
movlw b'00000100'
movwf TRISC
movlw b'00000111'
movwf TRISB
movlw .0
movwf ADCON1
bcf STATUS,RP0 ; switch to bank 0
movlw b'11000000'
movwf INTCON
movlw .0
movwf 0x10
bcf STATUS,RP0 ; switch to bank 0
movlw b'10000001'
movwf ADCON0
clrf PORTA
movlw b'00000111'
movwf PORTC
call LEVEL_3
movlw .5
movwf 0x3C
movwf 0x2A
movlw .10
movwf 0x3E
call LEVEL_4
call LEVEL_4
goto LEVEL_5
LEVEL_3 movlw .80
movwf W_TEMP
movlw .33
movwf FSR
LEVEL_6 clrf INDF
incf FSR,f
decfsz W_TEMP,f
goto LEVEL_6
return
ANASCAN movlw .5
movwf W_TEMP
LEVEL_7 decfsz W_TEMP,f
goto LEVEL_7
movf SEL_CHANEL,w
movwf W_TEMP
bcf STATUS,C
rlf W_TEMP,f
rlf W_TEMP,f
rlf W_TEMP,f
movlw .129
iorwf W_TEMP,w
movwf ADCON0
movlw .20
movwf 0x37
LEVEL_10 decfsz 0x37,f
goto LEVEL_8
goto LEVEL_9
LEVEL_8 btfss 0x2C,0
goto LEVEL_10
call LEVEL_11
LEVEL_9 bsf ADCON0,2
LEVEL_12 btfsc 0x2C,0
call LEVEL_11
btfsc ADCON0,2
goto LEVEL_12
movf ADRES,w
movwf AD_RESULT
bcf 0xC,6
return
isr bcf INTCON,GIE
movwf 0x31
movf STATUS,w
movwf 0x30
bcf 0xC,0
bcf 0x10,0
btfsc 0x2B,0
goto LEVEL_13
btfsc 0x2C,3
goto LEVEL_14
goto exit
LEVEL_16 bcf PORTC,4
bcf PORTC,5
movf 0x26,w
movwf TMR1L
comf TMR1L,f
movf 0x27,w
movwf TMR1H
comf TMR1H,f
bsf PORTC,0
bsf PORTC,1
bsf 0x2D,5
bsf 0x10,0
goto exit
LEVEL_14 btfss 0x2D,5
goto LEVEL_16
bcf PORTC,4
bcf PORTC,5
movf 0x28,w
movwf 0x26
movf 0x29,w
movwf 0x27
movf 0x24,w
movwf 0x22
movwf TMR1L
comf TMR1L,f
movf 0x25,w
movwf 0x23
movwf TMR1H
comf TMR1H,f
bcf PORTC,0
bcf PORTC,1
bcf 0x2D,5
bsf 0x10,0
goto exit
LEVEL_13 btfss 0x2D,5
goto LEVEL_17
bcf 0x2D,5
bsf 0x2C,0
movf 0x28,w
movwf 0x26
movf 0x29,w
movwf 0x27
movf 0x24,w
movwf 0x22
movwf TMR1L
comf TMR1L,f
movf 0x25,w
movwf 0x23
movwf TMR1H
comf TMR1H,f
movf 0x21,w
btfss STATUS,Z
goto LEVEL_18
movlw .8
xorwf 0x2B,f
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>
;DEAD BAND
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>
LEVEL_18 bsf 0x10,0
btfsc 0x2B,3
goto LEVEL_19
bcf PORTC,5
bsf PORTC,0
nop
nop
nop
nop
nop
bsf PORTC,4
bcf PORTC,1
goto exit
LEVEL_19 bcf PORTC,4
bsf PORTC,1
nop
nop
nop
nop
nop
bsf PORTC,5
bcf PORTC,0
goto exit
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>
;DEAD BAND
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>
LEVEL_17 bcf PORTC,4
bcf PORTC,5
movf 0x26,w
movwf TMR1L
comf TMR1L,f
movf 0x27,w
movwf TMR1H
comf TMR1H,f
bcf PORTC,0
bcf PORTC,1
bsf 0x2D,5
bsf 0x10,0
exit movf 0x30,w
movwf STATUS
movf 0x31,w
bsf INTCON,GIE
retfie
LEVEL_42 movlw .2 ;MAINS SENCE
movwf SEL_CHANEL
call ANASCAN ;LEVEL 21,22,23
movf AD_RESULT,w
sublw .67
btfsc STATUS,C
goto LEVEL_21
movf AD_RESULT,w
sublw .138
btfss STATUS,C
goto LEVEL_21
movf AD_RESULT,w
sublw .68
btfsc STATUS,C
goto LEVEL_22
movf AD_RESULT,w
sublw .135
btfsc STATUS,C
goto LEVEL_23
LEVEL_22 clrf 0x55
clrf 0x34
clrf 0x35
return
LEVEL_23 btfsc 0x2B,1
return
clrf 0x55
movlw .4
movwf 0x3D
movlw .1
addwf 0x34,f
btfss STATUS,C
return
incf 0x35,f
movf 0x35,w
sublw .50
btfsc STATUS,C
return
clrf 0x34
clrf 0x35
goto LEVEL_24
LEVEL_21 btfsc 0x2B,0
return
incf 0x55,f
clrf 0x34
clrf 0x35
movf 0x55,w
sublw .15
btfsc STATUS,C
return
goto LEVEL_25
LEVEL_40 btfss 0xC,2
goto LEVEL_26
bcf 0xC,2
clrf 0x36
goto LEVEL_27
LEVEL_26 btfss 0x2C,6
return
incf 0x36,f
movlw .4
subwf 0x36,w
btfss STATUS,C
return
clrf 0x36
LEVEL_25 btfss 0x2C,7
goto LEVEL_28
btfsc 0x2B,0
return
LEVEL_76 btfsc 0x2D,3
return
call LEVEL_29
movlw .7
movwf 0x38
call LEVEL_30
bsf PORTC,7
call LEVEL_4
call LEVEL_4
clrf 0x34
clrf 0x35
clrf 0x55
call LEVEL_31
bcf 0x2B,1
bcf PORTB,4
bcf PORTB,5
bcf 0x2D,3
bcf PORTB,7
movlw .10
movwf 0x3D
bsf 0x2B,0
movlw .0
movwf 0x21
call LEVEL_11
bsf 0x2D,5
movlw .200
movwf TMR1L
movlw .255
movwf TMR1H
bsf STATUS,RP0 ; switch to bank 1
bsf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bsf 0x10,0
bsf INTCON,GIE
clrf 0x40
clrf 0x41
clrf 0x42
clrf 0x4C
return
LEVEL_28 btfss 0x2C,3
goto LEVEL_32
call LEVEL_29
call LEVEL_31
LEVEL_32 clrf 0x55
bcf 0x2B,1
bcf PORTB,4
return
LEVEL_27 btfsc 0x2B,1
return
movlw .1
addwf 0x34,f
btfss STATUS,C
return
incf 0x35,f
movlw .10
movwf 0x3D
movf 0x35,w
sublw .2
btfsc STATUS,C
return
clrf 0x34
clrf 0x35
LEVEL_24 call LEVEL_33
bsf 0x2B,1
bsf PORTB,4
LEVEL_31 bcf PORTB,6
bcf 0x2C,3
movlw .100
movwf 0x54
movlw .50
movwf 0x2F
return
LEVEL_33 call LEVEL_29
call LEVEL_4
clrf 0x2E
clrf 0x3A
clrf 0x3B
bcf 0x2B,0
bcf 0x2D,3
bcf PORTB,7
bcf PORTB,5
bcf PORTC,7
call LEVEL_4
return
LEVEL_4 clrwdt
movlw .25
movwf 0x38
LEVEL_30 clrwdt
movlw .0
movwf W_TEMP
LEVEL_34 clrwdt
decfsz W_TEMP,f
goto LEVEL_34
decfsz 0x38,f
goto LEVEL_30
return
LEVEL_54 movlw .1 ; BATTERY SENCE
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
addwf 0x43,f
btfss STATUS,C
goto LEVEL_35
movf 0x44,w
addlw .1
movwf 0x44
LEVEL_35 movf 0x45,w
addlw .1
movwf 0x45
andlw .128
btfsc STATUS,Z
goto LEVEL_36
call LEVEL_37
movf BATTV,w
sublw .215 ;CHG CUT OFF
btfsc STATUS,C
goto LEVEL_36
call LEVEL_29
call LEVEL_31
LEVEL_36 goto LEVEL_38
LEVEL_29 bcf INTCON,GIE
bcf 0x10,0
bcf 0x12,2
bcf 0xC,0
bcf 0xC,2
bsf STATUS,RP0 ; switch to bank 1
bcf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bcf PORTC,4
bcf PORTC,5
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bsf PORTC,0
bsf PORTC,1
return
LEVEL_5 movlw .0
movwf TMR0
movlw .4
movwf 0x17
clrf 0x3A
clrf 0x3B
clrf 0x2E
movlw .10
movwf 0x39
movlw .100
movwf 0x54
movlw .10
movwf 0x3E
clrf 0x34
clrf 0x35
clrf 0x55
movlw .25
movwf 0x2A
movlw .50
movwf 0x2F
bcf 0x2C,7
bcf 0xC,2
movlw .10
movwf 0x3D
bcf PORTC,7
call LEVEL_4
call LEVEL_4
call LEVEL_4
LEVEL_38 clrwdt
bcf 0x2C,6
btfsc INTCON,T0IF
bsf 0x2C,6
bcf INTCON,T0IF
btfsc 0x2C,0
call LEVEL_11
btfsc PORTA,4
goto LEVEL_39
call LEVEL_40
goto LEVEL_41
LEVEL_39 call LEVEL_42
LEVEL_41 call LEVEL_43
btfsc 0x2B,1
goto LEVEL_44
goto LEVEL_45
LEVEL_45 btfss 0x2B,0
goto LEVEL_46
btfsc 0x2C,7
goto LEVEL_47
call LEVEL_33
goto LEVEL_46
LEVEL_47 movf 0x2E,w
btfss STATUS,Z
goto LEVEL_46
movlw .4 ;OVERLOAD SENCE
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
sublw .120
btfss STATUS,C
goto LEVEL_48
movf AD_RESULT,w
sublw .60
btfsc STATUS,C
goto LEVEL_49
movlw .10
movwf 0x3D
movlw .1
addwf 0x3A,f
btfss STATUS,C
goto LEVEL_49
incf 0x3B,f
movf 0x3B,w
sublw .5
btfsc STATUS,C
goto LEVEL_49
LEVEL_48 call LEVEL_29
clrf 0x3A
clrf 0x3B
movlw .50
movwf 0x2E
movlw .50
movwf 0x3D
bsf PORTB,5
goto LEVEL_46
LEVEL_49 bcf PORTB,5
movf BATTV,w
btfsc STATUS,Z
goto LEVEL_50
bcf 0x2D,3
sublw .154 ;LOW BATTERY BEEP
btfss STATUS,C
goto LEVEL_50
bsf 0x2D,3
movf BATTV,w
sublw .148 ;LOW BATTERY CUT
btfss STATUS,C
goto LEVEL_50
call LEVEL_29
bsf 0x2D,3
goto LEVEL_46
LEVEL_50 movlw .0 ;FEED BACK
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
addwf 0x40,f
btfss STATUS,C
goto LEVEL_51
movf 0x41,w
addlw .1
movwf 0x41
LEVEL_51 movf 0x42,w
addlw .1
movwf 0x42
andlw b'00100000'
btfsc STATUS,Z
goto LEVEL_46
call LEVEL_52
call LEVEL_53
LEVEL_46 goto LEVEL_54
LEVEL_44 btfss 0x2B,1
goto LEVEL_55
btfsc 0x2C,3
goto LEVEL_56
movf BATTV,w
sublw .201 ;CHG RESTART
btfss STATUS,C
goto LEVEL_55
movf 0x2F,w
btfss STATUS,Z
goto LEVEL_55
bsf 0x2C,3
bsf PORTB,4
bsf PORTB,6
clrf 0x46
clrf 0x47
clrf 0x48
clrf 0x4E
movlw .100
movwf 0x54
call LEVEL_57 ; LEVEL_57 = 0x346
movlw .200
movwf TMR1L
movlw .255
movwf TMR1H
bsf 0x2D,5
bsf STATUS,RP0 ; switch to bank 1
bsf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bsf 0x10,0
bsf INTCON,GIE
goto LEVEL_55
LEVEL_56 movlw .3 ;CHARGING CURRENT
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
sublw .180
btfsc STATUS,C
goto LEVEL_58
call LEVEL_29
call LEVEL_31
goto LEVEL_55
LEVEL_58 movf AD_RESULT,w
addwf 0x46,f
btfss STATUS,C
goto LEVEL_59
movf 0x47,w
addlw .1
movwf 0x47
LEVEL_59 movf 0x48,w
addlw .1
movwf 0x48
andlw .32
btfsc STATUS,Z
goto LEVEL_55
call LEVEL_60
call LEVEL_61
LEVEL_55 goto LEVEL_54
LEVEL_52 movlw .5
movwf W_TEMP
LEVEL_62 bcf STATUS,C
rrf 0x41,f
rrf 0x40,f
decfsz W_TEMP,f
goto LEVEL_62
movf 0x40,w
movwf 0x4C
clrf 0x40
clrf 0x41
clrf 0x42
return
LEVEL_37 movlw .7
movwf W_TEMP
LEVEL_63 bcf STATUS,C
rrf 0x44,f
rrf 0x43,f
decfsz W_TEMP,f
goto LEVEL_63
movf 0x43,w
movwf BATTV
clrf 0x43
clrf 0x44
clrf 0x45
return
LEVEL_60 movlw .5
movwf W_TEMP
LEVEL_64 bcf STATUS,C
rrf 0x47,f
rrf 0x46,f
decfsz W_TEMP,f
goto LEVEL_64
movf 0x46,w
movwf 0x4E
clrf 0x46
clrf 0x47
clrf 0x48
return
LEVEL_43 btfss 0x2C,6
goto LEVEL_65
btfss 0x2C,3
goto LEVEL_66
btfsc 0x2C,5
goto LEVEL_66
movlw .128
subwf 0x54,w
btfsc STATUS,C
goto LEVEL_67
incf 0x54,f
goto LEVEL_67
LEVEL_66 btfss 0x2B,0
goto LEVEL_67
btfsc 0x2B,7
goto LEVEL_67
movlw .128
subwf 0x39,w
btfsc STATUS,C
goto LEVEL_67
incf 0x39,f
LEVEL_67 btfsc PORTB,2
goto LEVEL_68
movf 0x2A,w
btfsc STATUS,Z
goto LEVEL_69
decfsz 0x2A,f
goto LEVEL_70
btfsc 0x2B,5
goto LEVEL_69
bsf 0x2B,5
btfsc 0x2C,7
goto LEVEL_71
bsf 0x2C,7
bsf PORTB,3
movlw .10
movwf 0x3D
goto LEVEL_70
LEVEL_71 bcf 0x2C,7
bcf PORTB,3
movlw .10
movwf 0x3D
btfsc 0x2B,0
call LEVEL_33
movlw .10
movwf 0x39
movlw .10
movwf 0x3E
goto LEVEL_70
LEVEL_68 bcf 0x2B,5
LEVEL_69 movlw .30
movwf 0x2A
LEVEL_70 decfsz 0x3C,f
goto LEVEL_65
movlw .20
movwf 0x3C
btfss 0x2D,3
goto LEVEL_72
movlw .10
movwf 0x3D
movlw .128
xorwf PORTB,f
LEVEL_72 btfss 0x2B,1
goto LEVEL_73
btfss 0x2C,3
goto LEVEL_74
movlw .64
xorwf PORTB,f
LEVEL_74 movf 0x2F,w
btfss STATUS,Z
decf 0x2F,f
LEVEL_73 btfss 0x2B,0
goto LEVEL_75
movf 0x2E,w
btfsc STATUS,Z
goto LEVEL_75
decfsz 0x2E,f
goto LEVEL_75
movlw .10
movwf 0x39
movlw .10
movwf 0x3E
call LEVEL_76
LEVEL_75 movf 0x3D,w
btfsc STATUS,Z
goto LEVEL_65
movlw b'1000000'
xorwf PORTC,f
decfsz 0x3D,f
goto LEVEL_65
bcf PORTC,6
LEVEL_65 return
LEVEL_61 movf 0x4E,w
sublw .5
btfsc STATUS,C
goto LEVEL_57
bcf 0x2C,5
movf 0x4E,w
subwf 0x54,w
movwf 0x52
btfss STATUS,C
goto LEVEL_77
sublw .2
btfss STATUS,C
goto LEVEL_78
return
LEVEL_78 bcf STATUS,C
rrf 0x52,f
clrf 0x53
movlw .1
movwf 0x52
movf 0x24,w
addwf 0x52,f
btfsc STATUS,C
incf 0x53,f
movf 0x25,w
addwf 0x53,f
movf 0x52,w
sublw .0
movf 0x53,w
movwf W_TEMP
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
btfsc STATUS,C
goto LEVEL_79
movlw .0
movwf 0x24
movlw .2
movwf 0x25
goto LEVEL_80
LEVEL_79 movf 0x52,w
movwf 0x24
movf 0x53,w
movwf 0x25
goto LEVEL_80
LEVEL_77 comf 0x52,f
incf 0x52,f
movf 0x52,w
sublw .2
btfsc STATUS,C
return
bcf STATUS,C
rrf 0x52,f
clrf 0x53
movlw .5
movwf 0x52
movf 0x52,w
subwf 0x24,f
movwf 0x52
btfss STATUS,C
incf 0x53,f
movf 0x53,w
subwf 0x25,f
movwf 0x53
btfsc STATUS,C
goto LEVEL_80
LEVEL_57 bsf 0x2C,5
movlw .20
movwf 0x24
movlw .0
movwf 0x25
LEVEL_80 bcf STATUS,C
movf 0x25,w
movwf W_TEMP
movf 0x24,w
sublw .200
movwf 0x28
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
movwf 0x29
return
LEVEL_53 movf 0x4C,w
sublw .5
btfsc STATUS,C
goto LEVEL_81
bcf 0x2B,7
bcf 0x2B,2
movf 0x4C,w
subwf 0x39,w
movwf 0x52
btfsc STATUS,C
goto LEVEL_82
bsf 0x2B,2
comf 0x52,f
incf 0x52,f
LEVEL_82 movf 0x52,w
sublw .2
btfss STATUS,C
goto LEVEL_83
return
LEVEL_83 bcf STATUS,C
rrf 0x52,f
rrf 0x52,f
movlw .1
movwf 0x52
btfss 0x2B,2
goto LEVEL_84
movf 0x52,w
subwf 0x3E,f
movf 0x3E,w
sublw .89
btfss STATUS,C
goto LEVEL_85
return
LEVEL_84 movf 0x52,w
addwf 0x3E,f
movf 0x3E,w
sublw .89
btfsc STATUS,C
return
movlw .89
movwf 0x3E
return
LEVEL_81 bsf 0x2B,7
movlw .10
movwf 0x39
LEVEL_85 movlw .10
movwf 0x3E
return
LEVEL_11 bcf 0x2C,0
incf 0x21,f
btfss 0x21,6
goto LEVEL_86
clrf 0x21
LEVEL_86 movf 0x21,w
call table
movwf 0x50
movf 0x3E,w
movwf 0x51
call LEVEL_88
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
movf 0x52,w
movwf 0x24
movf 0x53,w
movwf 0x25
bcf STATUS,C
movf 0x24,w
sublw .200
movwf 0x28
movf 0x25,w
movwf W_TEMP
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
movwf 0x29
return
LEVEL_88 clrf 0x53
clrf 0x52
movf 0x50,w
bcf STATUS,C
btfsc 0x51,0
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,1
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,2
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,3
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,4
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,5
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,6
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,7
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
retlw .0
end
em có đoạn code asm cần chuyển qua dạng flowchart algorithm.nhưng em đọc code k hiểu chức năng
các bác làm ơn bỏ chút thời gian giúp em với. em đang cần gấp mail của em đây : single.dkny@gmail.com (rep cho em sớm nhé.)
LIST P=16F72, F=INHX8M
include "P16F72.inc"
__config _HS_OSC & _WDT_ON & _PWRTE_ON & _CP_OFF
W_TEMP equ 0x20
BATTV equ 0x4D
AD_RESULT equ 0x33
SEL_CHANEL equ 0x32
goto init
nop
nop
nop
goto isr
nop
nop
nop
table ADDWF PCL , F
RETLW .0
RETLW .6
RETLW .13
RETLW .19
RETLW .25
RETLW .31
RETLW .37
RETLW .43
RETLW .49
RETLW .55
RETLW .60
RETLW .66
RETLW .71
RETLW .76
RETLW .81
RETLW .86
RETLW .91
RETLW .95
RETLW .99
RETLW .103
RETLW .106
RETLW .110
RETLW .113
RETLW .116
RETLW .118
RETLW .121
RETLW .122
RETLW .124
RETLW .126
RETLW .127
RETLW .127
RETLW .128
RETLW .128
RETLW .128
RETLW .127
RETLW .127
RETLW .126
RETLW .124
RETLW .122
RETLW .121
RETLW .118
RETLW .116
RETLW .113
RETLW .110
RETLW .106
RETLW .103
RETLW .99
RETLW .95
RETLW .91
RETLW .86
RETLW .81
RETLW .76
RETLW .71
RETLW .66
RETLW .60
RETLW .55
RETLW .49
RETLW .43
RETLW .37
RETLW .31
RETLW .25
RETLW .19
RETLW .13
RETLW .6
RETLW .0
init clrf STATUS
clrf PORTC
clrf PORTB
bcf STATUS,RP1
bsf STATUS,RP0 ; switch to bank 1
movlw b'11000111'
movwf OPTION_REG
movlw b'111111'
movwf TRISA
movlw b'00000100'
movwf TRISC
movlw b'00000111'
movwf TRISB
movlw .0
movwf ADCON1
bcf STATUS,RP0 ; switch to bank 0
movlw b'11000000'
movwf INTCON
movlw .0
movwf 0x10
bcf STATUS,RP0 ; switch to bank 0
movlw b'10000001'
movwf ADCON0
clrf PORTA
movlw b'00000111'
movwf PORTC
call LEVEL_3
movlw .5
movwf 0x3C
movwf 0x2A
movlw .10
movwf 0x3E
call LEVEL_4
call LEVEL_4
goto LEVEL_5
LEVEL_3 movlw .80
movwf W_TEMP
movlw .33
movwf FSR
LEVEL_6 clrf INDF
incf FSR,f
decfsz W_TEMP,f
goto LEVEL_6
return
ANASCAN movlw .5
movwf W_TEMP
LEVEL_7 decfsz W_TEMP,f
goto LEVEL_7
movf SEL_CHANEL,w
movwf W_TEMP
bcf STATUS,C
rlf W_TEMP,f
rlf W_TEMP,f
rlf W_TEMP,f
movlw .129
iorwf W_TEMP,w
movwf ADCON0
movlw .20
movwf 0x37
LEVEL_10 decfsz 0x37,f
goto LEVEL_8
goto LEVEL_9
LEVEL_8 btfss 0x2C,0
goto LEVEL_10
call LEVEL_11
LEVEL_9 bsf ADCON0,2
LEVEL_12 btfsc 0x2C,0
call LEVEL_11
btfsc ADCON0,2
goto LEVEL_12
movf ADRES,w
movwf AD_RESULT
bcf 0xC,6
return
isr bcf INTCON,GIE
movwf 0x31
movf STATUS,w
movwf 0x30
bcf 0xC,0
bcf 0x10,0
btfsc 0x2B,0
goto LEVEL_13
btfsc 0x2C,3
goto LEVEL_14
goto exit
LEVEL_16 bcf PORTC,4
bcf PORTC,5
movf 0x26,w
movwf TMR1L
comf TMR1L,f
movf 0x27,w
movwf TMR1H
comf TMR1H,f
bsf PORTC,0
bsf PORTC,1
bsf 0x2D,5
bsf 0x10,0
goto exit
LEVEL_14 btfss 0x2D,5
goto LEVEL_16
bcf PORTC,4
bcf PORTC,5
movf 0x28,w
movwf 0x26
movf 0x29,w
movwf 0x27
movf 0x24,w
movwf 0x22
movwf TMR1L
comf TMR1L,f
movf 0x25,w
movwf 0x23
movwf TMR1H
comf TMR1H,f
bcf PORTC,0
bcf PORTC,1
bcf 0x2D,5
bsf 0x10,0
goto exit
LEVEL_13 btfss 0x2D,5
goto LEVEL_17
bcf 0x2D,5
bsf 0x2C,0
movf 0x28,w
movwf 0x26
movf 0x29,w
movwf 0x27
movf 0x24,w
movwf 0x22
movwf TMR1L
comf TMR1L,f
movf 0x25,w
movwf 0x23
movwf TMR1H
comf TMR1H,f
movf 0x21,w
btfss STATUS,Z
goto LEVEL_18
movlw .8
xorwf 0x2B,f
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>
;DEAD BAND
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>
LEVEL_18 bsf 0x10,0
btfsc 0x2B,3
goto LEVEL_19
bcf PORTC,5
bsf PORTC,0
nop
nop
nop
nop
nop
bsf PORTC,4
bcf PORTC,1
goto exit
LEVEL_19 bcf PORTC,4
bsf PORTC,1
nop
nop
nop
nop
nop
bsf PORTC,5
bcf PORTC,0
goto exit
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>
;DEAD BAND
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>
LEVEL_17 bcf PORTC,4
bcf PORTC,5
movf 0x26,w
movwf TMR1L
comf TMR1L,f
movf 0x27,w
movwf TMR1H
comf TMR1H,f
bcf PORTC,0
bcf PORTC,1
bsf 0x2D,5
bsf 0x10,0
exit movf 0x30,w
movwf STATUS
movf 0x31,w
bsf INTCON,GIE
retfie
LEVEL_42 movlw .2 ;MAINS SENCE
movwf SEL_CHANEL
call ANASCAN ;LEVEL 21,22,23
movf AD_RESULT,w
sublw .67
btfsc STATUS,C
goto LEVEL_21
movf AD_RESULT,w
sublw .138
btfss STATUS,C
goto LEVEL_21
movf AD_RESULT,w
sublw .68
btfsc STATUS,C
goto LEVEL_22
movf AD_RESULT,w
sublw .135
btfsc STATUS,C
goto LEVEL_23
LEVEL_22 clrf 0x55
clrf 0x34
clrf 0x35
return
LEVEL_23 btfsc 0x2B,1
return
clrf 0x55
movlw .4
movwf 0x3D
movlw .1
addwf 0x34,f
btfss STATUS,C
return
incf 0x35,f
movf 0x35,w
sublw .50
btfsc STATUS,C
return
clrf 0x34
clrf 0x35
goto LEVEL_24
LEVEL_21 btfsc 0x2B,0
return
incf 0x55,f
clrf 0x34
clrf 0x35
movf 0x55,w
sublw .15
btfsc STATUS,C
return
goto LEVEL_25
LEVEL_40 btfss 0xC,2
goto LEVEL_26
bcf 0xC,2
clrf 0x36
goto LEVEL_27
LEVEL_26 btfss 0x2C,6
return
incf 0x36,f
movlw .4
subwf 0x36,w
btfss STATUS,C
return
clrf 0x36
LEVEL_25 btfss 0x2C,7
goto LEVEL_28
btfsc 0x2B,0
return
LEVEL_76 btfsc 0x2D,3
return
call LEVEL_29
movlw .7
movwf 0x38
call LEVEL_30
bsf PORTC,7
call LEVEL_4
call LEVEL_4
clrf 0x34
clrf 0x35
clrf 0x55
call LEVEL_31
bcf 0x2B,1
bcf PORTB,4
bcf PORTB,5
bcf 0x2D,3
bcf PORTB,7
movlw .10
movwf 0x3D
bsf 0x2B,0
movlw .0
movwf 0x21
call LEVEL_11
bsf 0x2D,5
movlw .200
movwf TMR1L
movlw .255
movwf TMR1H
bsf STATUS,RP0 ; switch to bank 1
bsf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bsf 0x10,0
bsf INTCON,GIE
clrf 0x40
clrf 0x41
clrf 0x42
clrf 0x4C
return
LEVEL_28 btfss 0x2C,3
goto LEVEL_32
call LEVEL_29
call LEVEL_31
LEVEL_32 clrf 0x55
bcf 0x2B,1
bcf PORTB,4
return
LEVEL_27 btfsc 0x2B,1
return
movlw .1
addwf 0x34,f
btfss STATUS,C
return
incf 0x35,f
movlw .10
movwf 0x3D
movf 0x35,w
sublw .2
btfsc STATUS,C
return
clrf 0x34
clrf 0x35
LEVEL_24 call LEVEL_33
bsf 0x2B,1
bsf PORTB,4
LEVEL_31 bcf PORTB,6
bcf 0x2C,3
movlw .100
movwf 0x54
movlw .50
movwf 0x2F
return
LEVEL_33 call LEVEL_29
call LEVEL_4
clrf 0x2E
clrf 0x3A
clrf 0x3B
bcf 0x2B,0
bcf 0x2D,3
bcf PORTB,7
bcf PORTB,5
bcf PORTC,7
call LEVEL_4
return
LEVEL_4 clrwdt
movlw .25
movwf 0x38
LEVEL_30 clrwdt
movlw .0
movwf W_TEMP
LEVEL_34 clrwdt
decfsz W_TEMP,f
goto LEVEL_34
decfsz 0x38,f
goto LEVEL_30
return
LEVEL_54 movlw .1 ; BATTERY SENCE
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
addwf 0x43,f
btfss STATUS,C
goto LEVEL_35
movf 0x44,w
addlw .1
movwf 0x44
LEVEL_35 movf 0x45,w
addlw .1
movwf 0x45
andlw .128
btfsc STATUS,Z
goto LEVEL_36
call LEVEL_37
movf BATTV,w
sublw .215 ;CHG CUT OFF
btfsc STATUS,C
goto LEVEL_36
call LEVEL_29
call LEVEL_31
LEVEL_36 goto LEVEL_38
LEVEL_29 bcf INTCON,GIE
bcf 0x10,0
bcf 0x12,2
bcf 0xC,0
bcf 0xC,2
bsf STATUS,RP0 ; switch to bank 1
bcf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bcf PORTC,4
bcf PORTC,5
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
bsf PORTC,0
bsf PORTC,1
return
LEVEL_5 movlw .0
movwf TMR0
movlw .4
movwf 0x17
clrf 0x3A
clrf 0x3B
clrf 0x2E
movlw .10
movwf 0x39
movlw .100
movwf 0x54
movlw .10
movwf 0x3E
clrf 0x34
clrf 0x35
clrf 0x55
movlw .25
movwf 0x2A
movlw .50
movwf 0x2F
bcf 0x2C,7
bcf 0xC,2
movlw .10
movwf 0x3D
bcf PORTC,7
call LEVEL_4
call LEVEL_4
call LEVEL_4
LEVEL_38 clrwdt
bcf 0x2C,6
btfsc INTCON,T0IF
bsf 0x2C,6
bcf INTCON,T0IF
btfsc 0x2C,0
call LEVEL_11
btfsc PORTA,4
goto LEVEL_39
call LEVEL_40
goto LEVEL_41
LEVEL_39 call LEVEL_42
LEVEL_41 call LEVEL_43
btfsc 0x2B,1
goto LEVEL_44
goto LEVEL_45
LEVEL_45 btfss 0x2B,0
goto LEVEL_46
btfsc 0x2C,7
goto LEVEL_47
call LEVEL_33
goto LEVEL_46
LEVEL_47 movf 0x2E,w
btfss STATUS,Z
goto LEVEL_46
movlw .4 ;OVERLOAD SENCE
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
sublw .120
btfss STATUS,C
goto LEVEL_48
movf AD_RESULT,w
sublw .60
btfsc STATUS,C
goto LEVEL_49
movlw .10
movwf 0x3D
movlw .1
addwf 0x3A,f
btfss STATUS,C
goto LEVEL_49
incf 0x3B,f
movf 0x3B,w
sublw .5
btfsc STATUS,C
goto LEVEL_49
LEVEL_48 call LEVEL_29
clrf 0x3A
clrf 0x3B
movlw .50
movwf 0x2E
movlw .50
movwf 0x3D
bsf PORTB,5
goto LEVEL_46
LEVEL_49 bcf PORTB,5
movf BATTV,w
btfsc STATUS,Z
goto LEVEL_50
bcf 0x2D,3
sublw .154 ;LOW BATTERY BEEP
btfss STATUS,C
goto LEVEL_50
bsf 0x2D,3
movf BATTV,w
sublw .148 ;LOW BATTERY CUT
btfss STATUS,C
goto LEVEL_50
call LEVEL_29
bsf 0x2D,3
goto LEVEL_46
LEVEL_50 movlw .0 ;FEED BACK
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
addwf 0x40,f
btfss STATUS,C
goto LEVEL_51
movf 0x41,w
addlw .1
movwf 0x41
LEVEL_51 movf 0x42,w
addlw .1
movwf 0x42
andlw b'00100000'
btfsc STATUS,Z
goto LEVEL_46
call LEVEL_52
call LEVEL_53
LEVEL_46 goto LEVEL_54
LEVEL_44 btfss 0x2B,1
goto LEVEL_55
btfsc 0x2C,3
goto LEVEL_56
movf BATTV,w
sublw .201 ;CHG RESTART
btfss STATUS,C
goto LEVEL_55
movf 0x2F,w
btfss STATUS,Z
goto LEVEL_55
bsf 0x2C,3
bsf PORTB,4
bsf PORTB,6
clrf 0x46
clrf 0x47
clrf 0x48
clrf 0x4E
movlw .100
movwf 0x54
call LEVEL_57 ; LEVEL_57 = 0x346
movlw .200
movwf TMR1L
movlw .255
movwf TMR1H
bsf 0x2D,5
bsf STATUS,RP0 ; switch to bank 1
bsf 0x8C,0
bcf STATUS,RP0 ; switch to bank 0
bsf 0x10,0
bsf INTCON,GIE
goto LEVEL_55
LEVEL_56 movlw .3 ;CHARGING CURRENT
movwf SEL_CHANEL
call ANASCAN
movf AD_RESULT,w
sublw .180
btfsc STATUS,C
goto LEVEL_58
call LEVEL_29
call LEVEL_31
goto LEVEL_55
LEVEL_58 movf AD_RESULT,w
addwf 0x46,f
btfss STATUS,C
goto LEVEL_59
movf 0x47,w
addlw .1
movwf 0x47
LEVEL_59 movf 0x48,w
addlw .1
movwf 0x48
andlw .32
btfsc STATUS,Z
goto LEVEL_55
call LEVEL_60
call LEVEL_61
LEVEL_55 goto LEVEL_54
LEVEL_52 movlw .5
movwf W_TEMP
LEVEL_62 bcf STATUS,C
rrf 0x41,f
rrf 0x40,f
decfsz W_TEMP,f
goto LEVEL_62
movf 0x40,w
movwf 0x4C
clrf 0x40
clrf 0x41
clrf 0x42
return
LEVEL_37 movlw .7
movwf W_TEMP
LEVEL_63 bcf STATUS,C
rrf 0x44,f
rrf 0x43,f
decfsz W_TEMP,f
goto LEVEL_63
movf 0x43,w
movwf BATTV
clrf 0x43
clrf 0x44
clrf 0x45
return
LEVEL_60 movlw .5
movwf W_TEMP
LEVEL_64 bcf STATUS,C
rrf 0x47,f
rrf 0x46,f
decfsz W_TEMP,f
goto LEVEL_64
movf 0x46,w
movwf 0x4E
clrf 0x46
clrf 0x47
clrf 0x48
return
LEVEL_43 btfss 0x2C,6
goto LEVEL_65
btfss 0x2C,3
goto LEVEL_66
btfsc 0x2C,5
goto LEVEL_66
movlw .128
subwf 0x54,w
btfsc STATUS,C
goto LEVEL_67
incf 0x54,f
goto LEVEL_67
LEVEL_66 btfss 0x2B,0
goto LEVEL_67
btfsc 0x2B,7
goto LEVEL_67
movlw .128
subwf 0x39,w
btfsc STATUS,C
goto LEVEL_67
incf 0x39,f
LEVEL_67 btfsc PORTB,2
goto LEVEL_68
movf 0x2A,w
btfsc STATUS,Z
goto LEVEL_69
decfsz 0x2A,f
goto LEVEL_70
btfsc 0x2B,5
goto LEVEL_69
bsf 0x2B,5
btfsc 0x2C,7
goto LEVEL_71
bsf 0x2C,7
bsf PORTB,3
movlw .10
movwf 0x3D
goto LEVEL_70
LEVEL_71 bcf 0x2C,7
bcf PORTB,3
movlw .10
movwf 0x3D
btfsc 0x2B,0
call LEVEL_33
movlw .10
movwf 0x39
movlw .10
movwf 0x3E
goto LEVEL_70
LEVEL_68 bcf 0x2B,5
LEVEL_69 movlw .30
movwf 0x2A
LEVEL_70 decfsz 0x3C,f
goto LEVEL_65
movlw .20
movwf 0x3C
btfss 0x2D,3
goto LEVEL_72
movlw .10
movwf 0x3D
movlw .128
xorwf PORTB,f
LEVEL_72 btfss 0x2B,1
goto LEVEL_73
btfss 0x2C,3
goto LEVEL_74
movlw .64
xorwf PORTB,f
LEVEL_74 movf 0x2F,w
btfss STATUS,Z
decf 0x2F,f
LEVEL_73 btfss 0x2B,0
goto LEVEL_75
movf 0x2E,w
btfsc STATUS,Z
goto LEVEL_75
decfsz 0x2E,f
goto LEVEL_75
movlw .10
movwf 0x39
movlw .10
movwf 0x3E
call LEVEL_76
LEVEL_75 movf 0x3D,w
btfsc STATUS,Z
goto LEVEL_65
movlw b'1000000'
xorwf PORTC,f
decfsz 0x3D,f
goto LEVEL_65
bcf PORTC,6
LEVEL_65 return
LEVEL_61 movf 0x4E,w
sublw .5
btfsc STATUS,C
goto LEVEL_57
bcf 0x2C,5
movf 0x4E,w
subwf 0x54,w
movwf 0x52
btfss STATUS,C
goto LEVEL_77
sublw .2
btfss STATUS,C
goto LEVEL_78
return
LEVEL_78 bcf STATUS,C
rrf 0x52,f
clrf 0x53
movlw .1
movwf 0x52
movf 0x24,w
addwf 0x52,f
btfsc STATUS,C
incf 0x53,f
movf 0x25,w
addwf 0x53,f
movf 0x52,w
sublw .0
movf 0x53,w
movwf W_TEMP
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
btfsc STATUS,C
goto LEVEL_79
movlw .0
movwf 0x24
movlw .2
movwf 0x25
goto LEVEL_80
LEVEL_79 movf 0x52,w
movwf 0x24
movf 0x53,w
movwf 0x25
goto LEVEL_80
LEVEL_77 comf 0x52,f
incf 0x52,f
movf 0x52,w
sublw .2
btfsc STATUS,C
return
bcf STATUS,C
rrf 0x52,f
clrf 0x53
movlw .5
movwf 0x52
movf 0x52,w
subwf 0x24,f
movwf 0x52
btfss STATUS,C
incf 0x53,f
movf 0x53,w
subwf 0x25,f
movwf 0x53
btfsc STATUS,C
goto LEVEL_80
LEVEL_57 bsf 0x2C,5
movlw .20
movwf 0x24
movlw .0
movwf 0x25
LEVEL_80 bcf STATUS,C
movf 0x25,w
movwf W_TEMP
movf 0x24,w
sublw .200
movwf 0x28
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
movwf 0x29
return
LEVEL_53 movf 0x4C,w
sublw .5
btfsc STATUS,C
goto LEVEL_81
bcf 0x2B,7
bcf 0x2B,2
movf 0x4C,w
subwf 0x39,w
movwf 0x52
btfsc STATUS,C
goto LEVEL_82
bsf 0x2B,2
comf 0x52,f
incf 0x52,f
LEVEL_82 movf 0x52,w
sublw .2
btfss STATUS,C
goto LEVEL_83
return
LEVEL_83 bcf STATUS,C
rrf 0x52,f
rrf 0x52,f
movlw .1
movwf 0x52
btfss 0x2B,2
goto LEVEL_84
movf 0x52,w
subwf 0x3E,f
movf 0x3E,w
sublw .89
btfss STATUS,C
goto LEVEL_85
return
LEVEL_84 movf 0x52,w
addwf 0x3E,f
movf 0x3E,w
sublw .89
btfsc STATUS,C
return
movlw .89
movwf 0x3E
return
LEVEL_81 bsf 0x2B,7
movlw .10
movwf 0x39
LEVEL_85 movlw .10
movwf 0x3E
return
LEVEL_11 bcf 0x2C,0
incf 0x21,f
btfss 0x21,6
goto LEVEL_86
clrf 0x21
LEVEL_86 movf 0x21,w
call table
movwf 0x50
movf 0x3E,w
movwf 0x51
call LEVEL_88
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
bcf STATUS,C
rrf 0x53,f
rrf 0x52,f
movf 0x52,w
movwf 0x24
movf 0x53,w
movwf 0x25
bcf STATUS,C
movf 0x24,w
sublw .200
movwf 0x28
movf 0x25,w
movwf W_TEMP
btfss STATUS,C
incf W_TEMP,f
movf W_TEMP,w
sublw .2
movwf 0x29
return
LEVEL_88 clrf 0x53
clrf 0x52
movf 0x50,w
bcf STATUS,C
btfsc 0x51,0
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,1
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,2
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,3
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,4
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,5
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,6
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
btfsc 0x51,7
addwf 0x53,f
rrf 0x53,f
rrf 0x52,f
retlw .0
end
Comment