Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
ORG 0x0004
;BTFSC CHG,1
;GOTO LED_IND
MOVWF R_72
MOVF STATUS,W
MOVWF R_70 ;satus_temp
MOVF PCLATH,W ;pc_temp
MOVWF R_71
CLRF PCLATH
BTFSC STATUS,RP0
GOTO Label_0002
GOTO Label_0004
Label_0002 MOVF R_72,W
BCF STATUS,RP0
MOVWF R_72
BSF STATUS,RP0
MOVF R_70,W
BCF STATUS,RP0
MOVWF R_70
BSF STATUS,RP0
MOVF R_71,W
BCF STATUS,RP0
MOVWF R_71
Label_0004 BTFSC R_22,5
GOTO Label_000B
MOVLW 0x81
BSF STATUS,RP0
MOVWF T2CON
BCF STATUS,RP0
BCF R_22,6
CLRF R_48
GOTO Label_000C
Label_000B BCF STATUS,Z
movlw 0X0B ;added for table read
subwf duty,w
BTFSS STATUS,Z
GOTO Label_000C
BCF STATUS,Z
MOVF 0x48,W
BTFSC STATUS,Z
BCF R_22,6
BTFSC STATUS,Z
GOTO Label_000C
MOVWF R_41
BSF R_22,6
BSF STATUS,RP0
INCF T2CON,f
BCF STATUS,RP0
Label_000C BCF STATUS,Z
movlw 0X01
subwf duty,w ;added for table read
BTFSS STATUS,Z
GOTO Label_000D
BTFSS R_43,0
GOTO Label_000E
BCF PORTC,2 ;CCP1 out
CLRF CCP1CON
CLRF CCPR1L
CLRF CCPR1H
MOVLW 0x0C
MOVWF CCP1CON
BCF R_43,0
BCF PORTC,1
BSF PORTC,3
MOVF R_45,W
MOVWF R_46
BTFSC R_43,1
BSF R_43,2
BTFSS R_43,1
BCF R_43,2
BTFSC R_22,1
GOTO Label_000F
DECFSZ R_4A,f
BTFSS R_43,2
BSF R_22,1
BTFSS R_43,2
GOTO Label_000F
DECF R_51,f
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
SUBWF R_51,W
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
BTFSS STATUS,C
MOVWF R_51
GOTO Label_000D
Label_000E BCF PORTC,2
CLRF CCP1CON
CLRF CCPR1L
CLRF CCPR1H
MOVLW 0x0C
MOVWF CCP1CON
BSF PORTC,1
BCF PORTC,3
BSF R_43,0
MOVF 0x45,W
MOVWF R_46
BTFSC R_43,1
BSF R_43,2
BTFSS R_43,1
BCF R_43,2
BTFSS R_22,1
GOTO Label_000D
Label_000F BCF STATUS,C
RRF R_46,f
BCF STATUS,C
RRF R_46,f
BTFSS R_43,2
GOTO Label_0010
MOVF R_46,W
SUBWF R_51,f
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY
BTFSS STATUS,C
MOVWF R_51
MOVF R_51,W
SUBLW 0x3F
;SUBLW 0x78
;MOVLW 0x79
MOVLW 0x40 ;64.8% DUTY ??????????
BTFSC STATUS,C
MOVWF 0x51
GOTO Label_000D
Label_0010 MOVF R_46,W
ADDWF R_51,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0xFF
SUBWF R_51,W
BTFSS STATUS , C
GOTO Label_000D
MOVLW 0xFE
MOVWF R_51
Label_000D CLRF R_53
movlw 0X07
movwf pclath
call table1
MOVWF R_3A
BCF STATUS,C
RRF R_3A,f
BCF STATUS,C
RRF R_3A,W
MOVWF R_3B
BCF STATUS,C
RRF R_3B,W
MOVWF R_3C
BCF STATUS,C
RRF R_3C,W
MOVWF R_3D
BCF STATUS,C
RRF R_3D,W
MOVWF R_3E
BCF STATUS,C
RRF R_3E,W
MOVWF R_3F
BCF STATUS,C
RRF R_3F,W
MOVWF R_40
COMF R_51,W
MOVWF R_58
DECF R_58,f
;movlw 0X60 ;?????????????????
MOVLW 0x80
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0012
Label_001A MOVLW 0x40
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0013
Label_001B MOVLW 0x20
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0014
Label_001C MOVLW 0x10
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0015
Label_001D MOVLW 0x08
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0016
Label_001E MOVLW 0x04
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0017
Label_001F MOVLW 0x02
SUBWF R_58,W
BTFSC STATUS,C
GOTO Label_0018
GOTO Label_0019
Label_0012 MOVF R_3A,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x80
SUBWF R_58 , f
GOTO Label_001A
Label_0013 MOVF R_3B,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x40
SUBWF R_58,f
GOTO Label_001B
Label_0014 MOVF R_3C,W
ADDWF R_53,f
BTFSC STATUS , C
GOTO Label_0011
MOVLW 0x20
SUBWF R_58,f
GOTO Label_001C
Label_0015 MOVF R_3D,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x10
SUBWF R_58,f
GOTO Label_001D
Label_0016 MOVF R_3E,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x08
SUBWF R_58,f
GOTO Label_001E
Label_0017 MOVF R_3F,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
MOVLW 0x04
SUBWF R_58,f
GOTO Label_001F
Label_0018 MOVF R_40,W
ADDWF R_53,f
BTFSC STATUS,C
GOTO Label_0011
Label_0019 BTFSC R_43,0
GOTO Label_0020
BCF PORTC,2 ;CCP1 out
CLRF CCPR1L
MOVF R_53,W
MOVWF CCPR1L
GOTO Label_0021
Label_0020 BCF PORTC,2
CLRF CCPR1L
MOVF R_53,W
MOVWF CCPR1L
Label_0021 movf duty,w
BCF STATUS,Z
sublw 0X4D
BTFSS STATUS,Z
GOTO Label_0022
movlw 0X00
movwf duty ;added for table read
Label_0022 incf duty,f ;added for table read
BCF STATUS,Z
movf duty,w
sublw 0X29
BTFSS STATUS,Z
GOTO Label_0023
BTFSS R_43,0
GOTO Label_0023
PWM_REG MOVLW b'10001001' ;RA1 for OUTPUT REGULATION
MOVWF ADCON0
MOVLW 0x1A
MOVWF R_42
LOOP_11 DECFSZ R_42,f
GOTO LOOP_11
BSF ADCON0,GO
Label_0025 BSF R_22,7
BTFSC ADCON0,GO
GOTO Label_0025
MOVF ADRES,W
SUBWF R_23,W
BTFSC STATUS,C
BSF R_43,01
BTFSS STATUS,C
BCF R_43,01
MOVWF R_45
BTFSS R_43,01
GOTO Label_0026
BTFSS R_22,01
GOTO Label_0027
SUBWF R_47,W
BTFSS STATUS,C
DECFSZ R_2F,f
GOTO Label_0027
;GOTO Label_0028 ;FOR SHT-CKT TRIP(close for no trip)
Label_0026 MOVLW 0x02
MOVWF R_2F
COMF R_45,f
INCF R_45,f
GOTO Label_0027 ;end_int_2
Label_0023 BCF PIR1,1 ;no TMR2 to PR2 match
BTFSS R_22,6
GOTO Label_0006
DECFSZ R_41,f
GOTO Label_0006
BSF STATUS,RP0 ;SELECT BANK1
DECF T2CON,f ; not known
BCF STATUS,RP0 ;SELECT BANK0
BCF R_22,6
Label_0027 BCF PIR1,1 ;;no TMR2 to PR2 match
Label_0006 BCF STATUS,RP0
BCF STATUS,RP1
MOVF R_70,W
MOVWF STATUS
MOVF R_71,W
MOVWF PCLATH
MOVF R_72,W
RETFIE
How to use code tags when including code to your post?
test code tags .........
How to use code tags when including code to your post?
test code tags .........
Can you please share your knowladge and your experience ?
INC_TRICKLE_DUTY: ;
'SELFCHECK PW,d'100' ;d'100'
if PWM_DUTY_CYLE > “?value?” then GOTO MAIN_FAILURE_CHECK
PWM_DUTY_CYLE = PWM_DUTY_CYLE +1
hpwm 1,PWM_DUTY_CYLE,PWM_FREQUENCY ' pwm on
;
goto main_failure_check
ASM Code:
INC_TRICKLE_DUTY:
SELFCHECK PW,d'100' ;d'100'
GOTO MAIN_FAILURE_CHECK
incf pw,1
movf pw,w
movwf ccpr1l
;call delay40
goto main_failure_check
When given 1: macro
selfcheck macro a, bxx
movlw bxx
xorwf a,0
btfsc status,z
endm
When given 2: Crystal = 16MHz
When given 3:
‘PWM Duty = (CCPR1L:CCP1CON(5:4)) x Tosc x TMR2 prescale.
MOVLW d'01'
MOVWF PW
MOVWF CCPR1L
BCF CCP1CON,4
BCF CCP1CON,5
BCF CCP1CON,0
BCF CCP1CON,1
BSF CCP1CON,2
BSF CCP1CON,3
MOVLW b'00000101'
MOVWF T2CON ‘TMR2 prescale =1:4
When given 3:
BSF STATUS,RP0
MOVLW d'166' ;6kHz CHARGING PWM
MOVWF PR2
BCF STATUS,RP0