Very strange problem with portb in 16F628

Status
Not open for further replies.

patroclus

New Member
Hi,
I get a very strange problem... using 16F628
I'm using RB0 and RB1 for serial ps/2 interfacing (clk and data lines).
It works great but when the program reaches some place RB0 and RB1 refuse to go low. I mean, if I clear its bit in portb register, the line never goes low again... This, of course, makes the whole circuit stop working.

After hours, I found that this begins to happend after executing this instruction:

bcf portb, 2h

I really don't undertand. If I erase this instruction, it works again...
portb is set all outputs except RB0 and RB1 which are toggle from input to output to get 5V from pull up resistor or ground.
I set comparator off, writting 0x7 to CMCON..

Any advice?? I really don't understand!
Thank you!
 
Read modify write

Are you aware of the "read-modify.write" behaviour?

It's the way ports in PICs work. Go to the manual. It is explained there.
 
If you read the other thread that you started you will see that I explained that this would happen and why.

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