Noman Yousaf
Full Member level 4
- Joined
- Nov 19, 2003
- Messages
- 208
- Helped
- 3
- Reputation
- 6
- Reaction score
- 2
- Trophy points
- 1,298
- Location
- Lahore Pakistan
- Activity points
- 1,763
hi all
i am not very new in assembly. but i am wondering that why i cant solve this very very simple I/O problem.
i want to use portc,2 and portc,3 as input an portc,4 and portc,5 as output and a simple delay.
(other all ports are set for their jobs)
when portc2 will hi, portc4 will lo and when portc2 will lo, portc4 will ho.
and same will be done with portc3 to portc5.
problem is, when only "chk_sw" routine is run, it works good and if i add a "delay", only portc,3 and portc,5 work, not portc2 and portc4.
I am getting mad that why delay is turning off the working of first portion of chk_sw routine.
can anybody help me.
i am stuck.
code is
i am not very new in assembly. but i am wondering that why i cant solve this very very simple I/O problem.
i want to use portc,2 and portc,3 as input an portc,4 and portc,5 as output and a simple delay.
(other all ports are set for their jobs)
when portc2 will hi, portc4 will lo and when portc2 will lo, portc4 will ho.
and same will be done with portc3 to portc5.
problem is, when only "chk_sw" routine is run, it works good and if i add a "delay", only portc,3 and portc,5 work, not portc2 and portc4.
I am getting mad that why delay is turning off the working of first portion of chk_sw routine.
can anybody help me.
i am stuck.
code is
Code:
LIST P=PIC16F887
PROCESSOR 16F887
#include "P16F887.INC"
BANKSEL TRISC
MOVLW 03FH
MOVWF TRISA
MOVLW 0FH
MOVWF TRISB
MOVLW 0CFH
MOVWF TRISC
MOVLW 00H
MOVWF TRISD
BANKSEL ANSEL
CLRF ANSEL
BANKSEL ANSELH
CLRF ANSELH
BANKSEL PORTA
MOVLW 0FFH
MOVWF PORTA
MOVWF PORTB
MOVWF PORTD
MOVLW 0CFH
MOVWF PORTC
MAIN:
CALL CHK_SW
CALL DELAY ;MAKE A DELAY
GOTO MAIN
DELAY:
MOVLW 08H
MOVWF 30H
MOVLW 0FFH
MOVWF 31H
MOVWF 32H
DECFSZ 32H,F
GOTO $-1
DECFSZ 31H,F
GOTO $-4
DECFSZ 30H,F
GOTO $-6
RETURN
CHK_SW:
BANKSEL PORTC
BTFSC PORTC,2
GOTO SW1_1
BSF PORTC,4
GOTO SW2_1
SW1_1:
BCF PORTC,4
SW2_1:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BTFSC PORTC,3
GOTO SW1_2
BSF PORTC,5
GOTO SW2_2
SW1_2:
BCF PORTC,5
SW2_2:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RETURN
END
Last edited by a moderator: