PDA

View Full Version : PIC16F917 - Not reading input



freddayz
- 14th July 2008, 23:53
All,

I am trying to read the input from RA7 from the PIC16F917. The problem is that I cannot do so. Does anyone know why? Thanks-N-Advance

INCLUDE "modedefs.bas"
DEFINE OSC 4 'SET OSCILLATOR SPEED TO 4 MHz
OSCCON = %01100111 'Enable internal oscillator
LCDCON=$40 'DISABLES LCD
CMCON0=$07 'DISABLES COMPARITORS
TRISA = %10101111 'Set PORTA IO Ports (0 = output, 1 = input)


MAIN:

PAUSE 1000

SEROUT PORTc.1,N9600,[13,10,"pic_mon = ",#PORTA.7,13,10]
GOTO MAIN
END

mackrackit
- 15th July 2008, 03:03
What do you have A.7 connected to? What are you expecting?

And the internal OSC may not be good enough for serial. What are you sending to?

Archangel
- 15th July 2008, 03:29
This chip has ADCON0, ADCON1, and ANSEL registers, all affect PortA

freddayz
- 15th July 2008, 20:19
mackrackit...

What do you have A.7 connected to? I have it connected to a GPIO which outputs 3.3VDC
What are you expecting? Either a logic 1 or 0

And the internal OSC may not be good enough for serial. What are you sending to? I am sending to the com port on the PC, it outputs the message i want.

skimask
- 15th July 2008, 20:59
What do you have A.7 connected to? >>>I have it connected to a GPIO which outputs 3.3VDC
Well, that isn't going to be near enough voltage to connect into an RS232 port on a PC... A 5v signal is just barely enough, but seems to work in most cases. Either need to bump up to 5v or use a 3v-compatible MAX232-type chip in the middle.


And the internal OSC may not be good enough for serial. What are you sending to? >>>I am sending to the com port on the PC, it outputs the message i want.
Internal oscillators are sometimes accurate enough for serial communications, sometimes not. Best bet is to use an external oscillator.

freddayz
- 15th July 2008, 21:48
I guess my question is not clear then...
I am trying to program RA7 on the PIC16F917 as an input with no success all I read is 0

mackrackit
- 15th July 2008, 21:57
As Joe mentioned about the ADC.
Take a look at this:
http://www.picbasic.co.uk/forum/showthread.php?t=561