PDA

View Full Version : Can't access Port A with PBP on 16F870.



CuriousOne
- 16th April 2013, 10:22
Hello. I'm doing certain project, where I needed enough pins to interface with keyboard and so on. So I've decided to use PIC16F870. I have no problems working with Port B and Port C, but can't get the Port A to work either as TTL input or output. I've tried TRISA=0, TRISA=1, to set it as output or input but no luck - still does not works. I even tried to insert the assembly code for setting port A as digital input,m as in datasheet of 16f870, it made a huge mess to program, still does not worked. Any ideas? wiring is correct, I've double checked.

HenrikOlsson
- 16th April 2013, 10:55
Try setting the pins to digital, ADCON1 = 7.

Sherbrook
- 16th April 2013, 10:57
When the PIC starts up port A is analogue. To change this to digital you have to set the ADCON1 register.
To make all port A digital you would include the line

ADCON1 = %00000110

Section 10 of the datasheet 'Analog-to-digital converter' explains this.
Phil

CuriousOne
- 16th April 2013, 11:28
Thanks, it works now.