1 Attachment(s)
PIC's ports individual bits manipulation - how to?
Hello,
In one of my projects, I have to adress the first (LSB) four bits of my PIC's PORTA.
This is done within a FOR...NEXT loop so the bits are adressed as a variable ("Digit").
I would like to use the other four bits for other purpose (Button, any Input...) but I can't make this the way I did it up to now.
How is it possible to handle ONLY those four bits wihtout modifying the other (MSB) four bits?
I've attached my code if you like to see how I've done it. Any comments/critics are very welcome.
I have to do it in "real"...
You may be right!
I just noticed that, using an additional microcontroler view in the simulator, the port doesn't change.
So I'm going to make it in "real".
Another thing; I have declared PORTA.6 as an Input (TRISA = %11110000). When I change this to an Output (TRISA = %10110000), the port will keep it's status as it should be.
Unfortunalety, I will need it as an Input.
I'll go back to my breadboard....
DCD works fine... and faster
Yes Paul, you're absolutely right.
The DCD command doesn't affect the input ports. Personally, I would appreciate to see this kind of information in the PBP manual. Maybe it will be there in the next edition?
As you mentionned, it is not a good idea to measure ports whithout pull-ups or pull-downs; what I did now.
So, DCD works fine and faster than indexing the ports.
Thank you very much.