I use PIC 16f877A and choose PORTA as input of my switchs and have pull-up resistor 10K. So the default state of pins in PORTA is high or logic '1'. But when I use MPlab to write code ASM for my MCU, after I set trisc for PORTA as input, the state of PORTA is '00000000' that cause my switchs in PORTA are always in LOW that active state and my ciruit run automaticly as i press all that switchs.
I tried to set trisc PORTA as ouput first, initialize its state as '11111111' and set trisc PORTA as input. But value of PORTA is only changed to '01000000', that still cause wrong when I conplie and simulate in Proteus.
I tried to put my switchs to PORTC and try âgain. It has no problem as in PORTA, state of PORTC after I set trisc for PORTC as input is '11111111' that make my ciruit run exactly.
Can anyone explain and help me to solve that problem? Thanks.
My code is:
BANKSEL TRISA
CLRF TRISA
BANKSEL PORTA
MOVLW 0FF
MOVWF PORTA
BANSEL TRISA
MOVLW 0FF
MOVWF TRISA
value of PORTA and TRISA after my code is:
TRISA : 11111111
PORTA : 01000000
I tried to set trisc PORTA as ouput first, initialize its state as '11111111' and set trisc PORTA as input. But value of PORTA is only changed to '01000000', that still cause wrong when I conplie and simulate in Proteus.
I tried to put my switchs to PORTC and try âgain. It has no problem as in PORTA, state of PORTC after I set trisc for PORTC as input is '11111111' that make my ciruit run exactly.
Can anyone explain and help me to solve that problem? Thanks.
My code is:
BANKSEL TRISA
CLRF TRISA
BANKSEL PORTA
MOVLW 0FF
MOVWF PORTA
BANSEL TRISA
MOVLW 0FF
MOVWF TRISA
value of PORTA and TRISA after my code is:
TRISA : 11111111
PORTA : 01000000