View previous topic :: View next topic |
Author |
Message |
picj1984
Joined: 01 Mar 2010 Posts: 73
|
How do I set APFCON register to change pin function w/ CCS? |
Posted: Mon Jun 21, 2010 2:48 pm |
|
|
I see in the Microchip datasheets where it says "Pin function is selectable via the APFCON register."
I'd like to be able to use this option with some of the CCP options and I notice there are several pins where, for example, CCP3 is listed on the PIC16F1933. It's listed under pin RB5 and pin RC6. How do I access the APFCON register in order to make this selection?
Thanks!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
picj1984
Joined: 01 Mar 2010 Posts: 73
|
|
Posted: Thu Jul 01, 2010 4:26 pm |
|
|
Thanks for the response. I've looked at that post in detail and I'm still having a little bit of trouble trying to figure this all out.
First, I should see if what I want to do is even possible.
I'm wanting to use the UART but ONLY the Rx pin. Not the Tx pin. I'd like to use that pin (Pin 17 on the PIC16F1933) as CCP3 instead.
Is this even possible?
I was hoping CCS could figure out what I wanted to do on it's own. Here's what I got at the header
Code: |
#include <16f1933.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#device ICD=TRUE
#include<stdlib.h>
#use delay(clock=16000000, int)
#use rs232(baud=31250,parity=N,stop=1,rcv=PIN_C7,bits=8)
|
Notice that I didn't include the xmit option since I don't want to use that pin as such
In the main() routine I got this going on
Code: |
setup_timer_0(T0_INTERNAL|T0_DIV_16);
//setup_timer_1(5|0);
//setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DIV_BY_1,175,1);
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER0);
//enable_interrupts(INT_TIMER1);
//enable_interrupts(INT_CCP1);
//enable_interrupts(INT_CCP2);
//setup_ccp2(CCP_COMPARE_INT);
setup_ccp3(CCP_PWM);
setup_ccp4(CCP_PWM);
//setup_ccp5(CCP_PWM);
|
This worked fine before I added in the UART stuff.
Interestingly enough, when I first added in the UART stuff I forgot to take otu the rcv option, and the UART worked fine, but obviously CCP3 wasn't working at all.
After I took the rcv option, CCP3 started working, but the UART only seems to work sporadically.
So... I'm thinking I have to do something manually in the APFCON register, but I can't figure out exactly how to do it. I know you alluded to how to do it in that last post, but I think I need more of a concrete example (as in the actual code since I'm still a bit of a newb).
Thanks so much!!
Joel |
|
|
picj1984
Joined: 01 Mar 2010 Posts: 73
|
|
Posted: Thu Jul 01, 2010 4:41 pm |
|
|
Hmm... I'm thinking this is not possible.
I just read this on page 294 of the datasheet in the EUSART section
Quote: |
Note 1:
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.
2: If the RX/DT function is on an analog pin,
the corresponding ANSEL bit must be
cleared for the receiver to function.
|
So it sounds like what I'm trying to do is impossible? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|