kitty_cute
Newbie level 6
MPLAB IDE v8.46
language use: assembly
part of program:
STARTUP code ; linker directive
goto Start
PORT1 code ; linker directive
Start
call InitLCD ; Initialize LCD registers
bsf STATUS,RP0 ; Bank 1
bsf TRISA,4 ; RA4 as input
bcf TRISD,1 ; set RD1 as motor output
movlw b'01110000' ; select the 8Mhz internal oscillator
movwf OSCCON movlw 0xFF ; select 7.9 kHz PWM
movwf PR2
bcf STATUS,RP0 ; Return to Bank 0
movlw b'00001100' ; pwm mode
movwf CCP2CON
bsf T2CON,TMR2ON ; turn on PWM
call InitLCD ; Initialize the LCD module
clrf CCPR2L ; Clear Duty Cycle
bsf ADCON0,ADON ; Turn the ADC module on
State1
clrf PORTD ; clear all portD
bsf PORTD,1
bsf PORTD,6
bsf PORTD,5
bcf PORTD,4 ;changes from bsf
btfsc PORTA,4 ; wait for switch to be press. YES or NO?
Goto State1 ; if no, go back state1
LoopOuter ; if switch is pressed.
bsf ADCON0,GO_DONE ; Start a conversion
bcf PORTD,1 ; On LED for Start/Stop
LoopInner
btfsc ADCON0,GO_DONE ; Wait for conversion to complete
goto LoopInner ; if not complete, go back reloop
movf ADRESH,w ; Move result to W
call DisplayDecimal ; Display the result (in decimal)
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
wish to make some adjustment on instead wait for the switch to be press , i wish someone can help me on change the code to press 1 time then the value will always show on LCD. press another time it will off.
Added after 56 seconds:
the code is to program a PIC chip pic16f917
language use: assembly
part of program:
STARTUP code ; linker directive
goto Start
PORT1 code ; linker directive
Start
call InitLCD ; Initialize LCD registers
bsf STATUS,RP0 ; Bank 1
bsf TRISA,4 ; RA4 as input
bcf TRISD,1 ; set RD1 as motor output
movlw b'01110000' ; select the 8Mhz internal oscillator
movwf OSCCON movlw 0xFF ; select 7.9 kHz PWM
movwf PR2
bcf STATUS,RP0 ; Return to Bank 0
movlw b'00001100' ; pwm mode
movwf CCP2CON
bsf T2CON,TMR2ON ; turn on PWM
call InitLCD ; Initialize the LCD module
clrf CCPR2L ; Clear Duty Cycle
bsf ADCON0,ADON ; Turn the ADC module on
State1
clrf PORTD ; clear all portD
bsf PORTD,1
bsf PORTD,6
bsf PORTD,5
bcf PORTD,4 ;changes from bsf
btfsc PORTA,4 ; wait for switch to be press. YES or NO?
Goto State1 ; if no, go back state1
LoopOuter ; if switch is pressed.
bsf ADCON0,GO_DONE ; Start a conversion
bcf PORTD,1 ; On LED for Start/Stop
LoopInner
btfsc ADCON0,GO_DONE ; Wait for conversion to complete
goto LoopInner ; if not complete, go back reloop
movf ADRESH,w ; Move result to W
call DisplayDecimal ; Display the result (in decimal)
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
wish to make some adjustment on instead wait for the switch to be press , i wish someone can help me on change the code to press 1 time then the value will always show on LCD. press another time it will off.
Added after 56 seconds:
the code is to program a PIC chip pic16f917