PDA

View Full Version : What do I have to disable ?



Glenn
- 21st January 2009, 01:19
I building a little thingie that are going to use alot of pins, and since some has to be analog, some CCP (PWM) and so on I really had to do some thinking of what pin to use where.

Well, then I choosed RA0 RA1 and RA2 for the three LED's, fine, in the beginning I just used RA0 and RA1 and no problem, then I started to use RA2.. didnt work. :(

It's nothing complicated, I just set all pins low in the beginning of the code, and just use:

high porta.0
high porta.2

..and so later on.

If I look at the datasheet pin 4 on 16F877A is:

RA2/AN2/Vref/CVref


..and pin 2 and 3 only is RA0/AN0 and RA1/AN1

So, Vref or CVref seem to be the problem, wise of my earlier mistakes I started with disabling the comparators with "CMCON = 7", didn't help :(

I tried to understand what do by reading the microchip dopcumentation, but no..

I guess that its something else I have to disable to be able to use RA2 as an digital IO-pin ?

anyone have an idea ?

Archangel
- 21st January 2009, 02:03
Read this post:http://www.picbasic.co.uk/forum/showthread.php?t=561

Glenn
- 13th February 2009, 00:21
Well, I readed it, but I still dont understand, I have readed the part in the datasheet about the ADC, and I guess its register 11-2 bit 0.3 I have to change, and since I use AN5,6,7 I dont really understand how to set this value.

I want to use AN0,AN1,AN2 as digital IO, AN5,AN6,AN7 as analog inputs, Vdd as Vref+ and Vss as Vref-

Is this possible ? or do I have to rethink ?

The page in the datasheet (for 16F87XA) I'm looking at is 130, "

Archangel
- 13th February 2009, 04:16
Well let's see what you got, post the code so we can see it.
GIVE THIS A TRY:
CCP1CON = 0 ' CAPTURE COMPARE MODULE DISABLED
CVRCON = 0 ' CVRCON BIT 7 =1 ENABLES =0 DISABLES CVRCON
ADCON0.0 = 0 ' TURN OFF A/D CONVERTER
ADCON1 = 6 ' CONFIGURE ALL PORTS AS DIGITAL