Now, how do I get the value of the Port if the port is less than 8 bits?
Thanks!
Now, how do I get the value of the Port if the port is less than 8 bits?
Thanks!
Exactly the same way as before.
On a 16F877, for example, PortA is 6bits. Reading it will return a byte with the state of the port pins in the lower 6 bits, the two high bits will always read zero.
PortE on the 16F877 is only 3bits. Reading it will return a byte with the state of the port pins in the lower 3 bits, the upper 5 bits will always read zero.
If you look at the register summary in the datasheet for the 16F877 (or whatever device you're actually using) it's all pretty clear.
/Henrik.
Yes, that makes good sense. But what if I only use say 4 bits of the PortA port in my code and make the other PortA bits as outputs? Would reading the port give me the correct result?
:-)
it will also return the state of the output. Nothing hard to solve through a bitwise operation or simply by breading the bits you need.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks