jz do it
Newbie level 3
hello all,
i'm new in microcontroller...
Recently,i would like to do a project regarding the used of PIC16F877.
So,i test my PIC's i/o first..all the output pins of my PIC can work well.(i test with led blinking program..
but when i test the input pins of porta and portb with the program at the bottom,
some of input pins seem like can't detect the input..
(rb2,rb3,rb4,rb5,rb7,ra1,ra2 and ra3)
is my pic broken already??
or my testing program is incorrect?
can anyone help me with this??thanks~
;testing PORTA input with PORTD as output
;testing PORTB input with PORTC as OUTPUT
LIST p=16F877
include "P16F877.inc"
cblock 0x20
tmp1
tmp2
ENDC
ORG 0x0000
;set ports
bcf STATUS,RP1
bsf STATUS,RP0
movlw 0xFF
movwf TRISA
movlw 0xFF
movwf TRISB
movlw 0x00
movwf TRISC
movlw 0x00
movwf TRISD
movlw 0x03
movwf TRISE
movlw 0x06
movwf ADCON1
movlw 0xFF
movwf OPTION_REG
bcf STATUS,RP0
clrf PORTA
clrf PORTB
clrf PORTC
clrf PORTD
clrf PORTE
goto Main
Main
clrf tmp1
clrf tmp2
call Check1
call Check2
movfw tmp1
movwf PORTD
movfw tmp2
movwf PORTC
goto Main
Check1
btfsc PORTA,0
bsf tmp1,0
btfsc PORTA,1
bsf tmp1,1
btfsc PORTA,2
bsf tmp1,2
btfsc PORTA,3
bsf tmp1,3
btfsc PORTA,4
bsf tmp1,4
btfsc PORTA,5
bsf tmp1,5
btfsc PORTE,0
bsf tmp1,6
btfsc PORTE,1
bsf tmp1,7
btfsc PORTE,2
bsf tmp1,7
return
Check2
btfsc PORTB,0
bsf tmp2,0
btfsc PORTB,1
bsf tmp2,1
btfsc PORTB,2
bsf tmp2,2
btfsc PORTB,3
bsf tmp2,3
btfsc PORTB,4
bsf tmp2,4
btfsc PORTB,5
bsf tmp2,5
btfsc PORTB,6
bsf tmp2,6
btfsc PORTB,7
bsf tmp2,7
return
end
i'm new in microcontroller...
Recently,i would like to do a project regarding the used of PIC16F877.
So,i test my PIC's i/o first..all the output pins of my PIC can work well.(i test with led blinking program..
but when i test the input pins of porta and portb with the program at the bottom,
some of input pins seem like can't detect the input..
(rb2,rb3,rb4,rb5,rb7,ra1,ra2 and ra3)
is my pic broken already??
or my testing program is incorrect?
can anyone help me with this??thanks~
;testing PORTA input with PORTD as output
;testing PORTB input with PORTC as OUTPUT
LIST p=16F877
include "P16F877.inc"
cblock 0x20
tmp1
tmp2
ENDC
ORG 0x0000
;set ports
bcf STATUS,RP1
bsf STATUS,RP0
movlw 0xFF
movwf TRISA
movlw 0xFF
movwf TRISB
movlw 0x00
movwf TRISC
movlw 0x00
movwf TRISD
movlw 0x03
movwf TRISE
movlw 0x06
movwf ADCON1
movlw 0xFF
movwf OPTION_REG
bcf STATUS,RP0
clrf PORTA
clrf PORTB
clrf PORTC
clrf PORTD
clrf PORTE
goto Main
Main
clrf tmp1
clrf tmp2
call Check1
call Check2
movfw tmp1
movwf PORTD
movfw tmp2
movwf PORTC
goto Main
Check1
btfsc PORTA,0
bsf tmp1,0
btfsc PORTA,1
bsf tmp1,1
btfsc PORTA,2
bsf tmp1,2
btfsc PORTA,3
bsf tmp1,3
btfsc PORTA,4
bsf tmp1,4
btfsc PORTA,5
bsf tmp1,5
btfsc PORTE,0
bsf tmp1,6
btfsc PORTE,1
bsf tmp1,7
btfsc PORTE,2
bsf tmp1,7
return
Check2
btfsc PORTB,0
bsf tmp2,0
btfsc PORTB,1
bsf tmp2,1
btfsc PORTB,2
bsf tmp2,2
btfsc PORTB,3
bsf tmp2,3
btfsc PORTB,4
bsf tmp2,4
btfsc PORTB,5
bsf tmp2,5
btfsc PORTB,6
bsf tmp2,6
btfsc PORTB,7
bsf tmp2,7
return
end