PDA

View Full Version : Read value of digital ports



NL2TTL
- 12th July 2005, 10:04
Does somebody know how to read the complete status of portb on a 6F870.

So i give one command and get the status of portb.0....portb.7, like when port b.0 and b.3 are high i get the value 5

NavMicroSystems
- 12th July 2005, 10:52
Value VAR BYTE
Value=PortB

mauro66
- 13th July 2005, 09:42
Dear Sir,
I tried to read from PORTA of a 16F872; on a demo, simple board it works, but on a more complex project board every time I tried to read something, the micro always read 4 or 0 (decimal). On the 8 pins of PORTA the single bits are exact.

Do you know what's the problem ?

Thanks,

Melanie
- 13th July 2005, 10:55
PortA comes up in ANALOG mode as default. See DATASHEET, Section 10-2, ADCON1 register. Select DIGITAL mode. See associated table.

mauro66
- 13th July 2005, 11:11
Sorry, I made a mistake in the previous message:
I'm working on PORTB as input, not on PORTA.
However I've already setted the port directions, for my project, in this manner:

Poke $9F,%00000110 ' Set PORTA as digital I/O
' $9F is address of ADCON1 register

TRISA = $00 ' Set PORTA as OUTPUT
TRISB = $FF ' Set PORTB as INPUT
TRISC = $00 ' Set PORTC as OUTPUT