Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

Back
Top