DISPLAY = .16 ; Display .128 = 128X84 graphic or Display .16 = LCD 16X2 character
IF DISPLAY == .16
call lcd_init
ENDIF
IF DISPLAY == .128
call glcd_init
ENDIF
shifteh
ok so i need to test more than one bit at a time my guess is use btfss and if it finds a 1 in the 0 bit then go to anouther btfss to check if the second bit is there but it would make the program quite long
whats this andwf and how would i act on the response or is it like btfss with 2 following lines like true, false
movlw b'00000001;
andwf PORTB,W
btfsc STATUS,Z ; if the result of the AND is Zero, the Z bit of the STATUS register is set to ONE
; you then check with btfsc/ss to see it the Z bit is 0 or 1
this is exactally what i need , thanks so much
so basically what im doing is watching porta for a high on bits 0 and 1 (up and down) then once detected it then goes and finds out which gear its is already in to know the next one to change to weither it be up or down
first gear 00011
second gear 00001
Third gear 00000
Forth gear 00010
thanks everyone for there helpwill test the andwf when i get back to my compiling pc
Try this program. It generates pic asm code for common c constructs such as if, for, while etc.
No install needed, just extract the files to a directory and run 'PicAsm12.exe'.
cblock 0x0C ; specify user variables ( registers)
GEAR_INPUT
SELECTOR
endc
org 0x00
goto start
list P=16F84A,
include <P16f84A.inc>
ERRORLEVEL -302
cblock 0x0C ; specify user variables ( registers)
endc
org 0x00
COUNT1 equ 08h
bsf 03h,5 ;Go to Bank 1
movlw b'00000' ;Put 00000 into W
movwf TRISA ;Move 00000 onto TRISA
movlw b'0000000'
movwf TRISB ; move 00000000 into trisb
bcf 03h,5 ;Come back to Bank 0
movlw b'00011' ;sets output as first gear
movwf PORTB ;portb
;----------------------------
; MAIN PROGRAMM LOOP
;----------------------------
main
Loop1 decfsz COUNT1,1 ; GEAR CHANGE DELAY , Count to 255 twice, 1 Second Delay Between Reading for a gear selection
goto Loop1 ;
Loop2 decfsz COUNT1,1 ;
goto Loop2
btfsc PORTA, 0 ;Is "UP" button pressed?
CALL GEARUP ;Higher gear selection has been made
btfsc PORTA, 1 ;Is "DOWN" button pressed?
CALL GEARDOWN ;Lower gear selection has been made
loop goto main
;----------------------------------------------------------------
; Gear selection subroutines
;-----------------------------------------------------------------
GEARUP
bcf PORTB, 3
btfsc PORTB, 0
goto FSU ;first and second
goto TFU ;Third and forth
FSU btfsc PORTB, 1
goto second_gear
goto third_gear
TFU btfss PORTB, 1
goto fourth_gear
bsf PORTB, 3
return
GEARDOWN
bcf PORTB, 3
btfsc PORTB, 0
goto FSD
goto TFD
FSD
btfss PORTB, 1
goto first_gear
bsf PORTB, 3 ;
return
TFD
btfss PORTB, 1
goto second_gear ; if 0
goto third_gear ; if 1
return
;------------------------------------------------------------
;GEAR Communication to Transmission
;------------------------------------------------------------
first_gear
movlw b'00011'
movwf PORTB
return
second_gear
movlw b'00001'
movwf PORTB
return
third_gear
movlw b'00'
movwf PORTB
return
fourth_gear
movlw b'00010'
movwf PORTB
return
end
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?