PIC 16F627A Programming problem

Status
Not open for further replies.

mas

New Member
I am using the chip pic 16f627a

setting PORTA to inputs & PORTB to outputs >>
Code:
bsf STATUS,PR0
movlw 0xFF
movwf TRISA
movlw 0x00
movwf TRISB
bcf STATUS,RP0


giving a high input to PORTA,0 >>
Code:
bsf PORTA,0
btfsc PORTA,0
******
$$$$$$

I used the btfsc(bit test skip if zero instruction) .. and the tested pin is set to '1' .. so the program shoudn't skip the ****** line


My problem is that the program skips the ****** instruction ,, and goes to the $$$$$$ instruction .. although the tested pin is set to high '1'

If any one knows where is the fault .. I am so gratefull
 
The pins of PORTA are configured as inputs.
Try this:
Code:
movlw 0x00
movwf TRISA
and see what happens.
 
eng1 said:
The pins of PORTA are configured as inputs.
Try this:
Code:
movlw 0x00
movwf TRISA
and see what happens.

Do you mean that if the pin is set to input .. Then I can't assign it to high or low ??
 
If I'm not mistaken, pins set as inputs have their bits set according to the incoming voltage level with VDD=Set and VSS=Unset. Don't forget to turn off the comparators to enable digital input.
 
mas said:
Do you mean that if the pin is set to input .. Then I can't assign it to high or low ??

If you want to set or clear a bit of PORTA in software, that pin is an output by definition.

When a pin is configured as an input you can read its value, which depends on the applied voltage, as TekNoir said.

I guess you're trying to emulate a switch. If so, you configured PORTA correctly, but the last bsf instruction makes no sense.
 
yes, I was trying to simulate

I will use a hardware circuit to test the program instead of the simulator

Thanks a lot guys
 
It is possible to apply a 'stimulus' with the simulator, but it's simple to add a switch with a pull-up resistor (external or internal) to your circuit.

Have fun
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…