PDA

View Full Version : PortC.7 general I/O output problem



bodgetts
- 31st July 2011, 00:00
I have a 16f887 PIC and I am using PortC for general output. If I toggle bits 0-7, only bits 0-6 are working. Bit 7 doesn't toggle as expected.

I am thinking that it may have something to do with my configuration, as RC7 is used for RX for serial. Maybe I haven't disabled the serial connection properly?

ADCON0 = 7 'Disable ADC
ADCON1 = 7

ANSEL=%00000000 'all analogue ports to digital
ANSELH=%00000000 'all analogue ports to digital
CM1CON0=%00000000 'disable COMPARATOR 1
CM2CON0=%00000000 'disable COMPARATOR 2
SSPCON=%00000000' disable SERIAL PORT
RCSTA=%00000000 'disable SERIAL PORT
PCON=%00000000 'disable BOR and ULPW
OPTION_REG=%00000000 'disable INTERNAL PULLUPS
WPUB=%00000000 'disable INDIVIDUAL PULLUPS
IOCB=%00000000 'disable INTERRUPT ON CHANGE
CCP1CON = 0 ' turn off CCP1 Module which affects portC
CCP2CON = 0 ' turn off CCP2 Module which affects portC
PSTRCON=%00000000 'disable PULSE STEERING MODE
T1CON=%00000000 'disable TIMER1

'All pins are outputs
trisa = 0
trisb = 0
trisc = 0
trisd = 0

Any suggestions?

mister_e
- 31st July 2011, 01:18
From the datasheet...

Note: When the SPEN bit is set the TX/CK I/O
pin is automatically configured as an
output, regardless of the state of the
corresponding TRIS bit and whether or not
the EUSART transmitter is enabled. The
PORT latch is disconnected from the
output driver so it is not possible to use the
TX/CK pin as a general purpose output.

You can't

bodgetts
- 31st July 2011, 07:53
I saw that, but I am talking about RC7, which is the RX pin.

The RC6 Pin (TX) which you are talking about seems to work as a general I/O. I was wondering why the RC7 / RX Pin won't work.

mister_e
- 31st July 2011, 08:59
Note 1: When the SPEN bit is set the RX/DT I/O pin
is automatically configured as an input,
regardless of the state of the corresponding
TRIS bit and whether or not the EUSART
receiver is enabled. The RX/DT pin data
can be read via a normal PORT read but
PORT latch data output is precluded.

You can't if you're using HSEROUT

cncmachineguy
- 31st July 2011, 11:01
Are you using hserout or hserin?

bodgetts
- 31st July 2011, 18:34
I am using neither hserout or hserin. I just want to use ports c.0 - c.7 for general output.

Have I configured my pic incorrectly?

cncmachineguy
- 31st July 2011, 19:19
I think NO! ADCON = 7 is the same as ADCON = %00000111. so you have enabled the a/d and turned it on. Please correct this and see if it helps. It looks like you DO have the serial disabled as you wanted to.

bodgetts
- 31st July 2011, 21:47
Ok, I changed the ADCON0 and ADCON1 to 0, still have the same problem. Portc.0-portc.6 work fine, it is just the last pin portc.7 that doesn't seem to change no matter what I send to it.

cncmachineguy
- 31st July 2011, 21:57
I don't see any reason for it not to work. Maybe the circuit is bad? Breadboard or SIM? How do you know it is not working?

mister_e
- 1st August 2011, 16:08
Please say SIM :D

cncmachineguy
- 1st August 2011, 16:18
breadboard - breadboard - breadboard - breadboard

Cmon Steve, say it with me.

mister_e
- 1st August 2011, 16:22
http://toons.artie.com/alphabet/ralph/arg-n-50-trans.gifhttp://toons.artie.com/alphabet/ralph/arg-o-5O-tRr-a-pl0ase-ns.gif

----===:D===----

bodgetts
- 2nd August 2011, 03:29
I am using one of those prototype boards with each individual hole plated so I can solder to it.

I have sent my design to the PCB makers, should be here tomorrow so I will see if the problem still persists. Hopefully it is just a dodgy connection somewhere, I do have a lot of wires :-)