And that's what's called "RTFM"
How do you convert that into a statement?
Well, that all comes back to the bare bones basics of dealing with microprocessors and microcontrollers and binary and being able to count in binary and being able to convert a binary number to either a format compatible with the compiler/assembler you're using and/or another Base.
As you said - "bit 3 needs to have a value of 1110"
A bit is a "Binary digIT". It can't have a value of 1110. Just like you can't count over 5 on one hand. Binary has 2 distinct states, 0 and 1, off and on. Therefore, you can only count 0 and 1...that's it. Nothing more, nothing less.
If you take another good look at that datasheet, you'll see that the ADCON register (and I think you really want the ADCON1 register) has 8 bits, like most other registers. While I'm not looking at the datasheet at the moment, I'll assume that those 4 data bits are the lowest significant data bits of that register. What about the other 4 data bits of the ADCON1 register BYTE?
Again, taking a look at the PBP manual, you'll see that you can assign individual bits to something by using the "%" character to signify a binary quantity.
Those bits described above are most likely the lowest significant 4 bits of the ADCON1 register. I'll assume that the upper 4 bits of the ADCON1 register should be set to 0000 for example purposes only.
Therefore...it follows, according to the PBP manual and it's explanation of the usage of the "%" character, you can set bits in any register or variable from most significant bit to least significant bit, left to right.
Hence
ADCON1 = %00001110
The leftmost 0 is the most significant bit, the rightmost 0 is the least significant bit. And following this example, this would tell me that I'm setting the ADCON register as follows:
Bit 7 = 0 = Left Justified
Bit 6 = 0 = Depending on the state of the ADCON0 register, sets the clock used by the A/D converter
Bit 5 = 0 = Unused bit - read as 0
Bit 4 = 0 = Unused bit - read as 0
Bit 3 thru Bit 0 = 1110 - Looking thru the table in the datasheet, this tells me that this combination of bits will set all dual purpose pins to digital with the exception of PortA.0 and the VRef+ and VRef- will be referenced to the PIC's positive rail and ground respectively.
If that answers your question, great.
If it's entirely too much 'duh' information, sorry, didn't mean to insult your intelligence.
Thinking about it though, what you might really be wanting is a combination of digital and analog ports that isn't available in this PIC (I remember this subject coming up some time ago)
For instance:
You can set all pins to digital, lowest 4 bits set to "011x"
You can set all pins to digital and PortA.0 to analog, lowest 4 bits set to "1110"
You CAN'T set PortA.0 and PortA.5 to analog and the rest to digital...because that combination of bits isn't in the table. I think you can actually pick and chose in some of the newer PICs, not sure, haven't tried.
Is that the ticket?
(EDIT: Re-reading your post above, I see that is in fact what you really wanted to do...Hopefully this clears it up for you)
Bookmarks