View previous topic :: View next topic |
Author |
Message |
caddy
Joined: 24 Jun 2007 Posts: 14
|
Possible to not specify xmit pin in #USE RS232 statement? |
Posted: Tue Jul 31, 2007 7:19 am |
|
|
Hi
I am using a hardware UART for receiving data. The UART does not need to send data. So technically I only need the RCV pin (PIN_C7), not the XMIT pin (PIN_C6).
The spec I'm working with requires the use of PIN_C6 as a digital input, entirely unrelated to the UART.
The problem is that when I have:
Code: |
#use rs232(baud=31250, rcv=PIN_C7, PARITY=N)
|
the #INT_RDA interrupt will not trigger at all. Simply changing the code to:
Code: |
#use rs232(baud=31250, xmit=PIN_C6, rcv=PIN_C7, PARITY=N)
|
makes the #INT_RDA interrupt trigger correctly.
But the problem is I need PIN_C6 as a digital input. How can I achieve this?
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Tue Jul 31, 2007 7:42 am |
|
|
Just specify it, and don't use it.
Turn off the transmit part of the UART, so there is no conflict.
There are three 'parts' to the #use RS232 operation. The specification, generates a tiny amount of code at the start of the program, which initialises the UART. Then when a putc is used, the code for this is added, and when a getc is used, the code for this is added. If you specify both pins, and don't ever use the putc function, the code doesn't get generated for this.
Then all you need do, is turn off the transmit part of the UART. This is the TXEN bit. You don't say whether this is a '16', or '18' chip, but all that is needed, is a #bit definition for this, and you can then turn the transmit part off.
For a '18',
#byte TXSTA=0xFAC
#bit TXEN=TXSTA.5
Then if you set:
TXEN=false;
The pin will behave as normal.
Best Wishes |
|
|
caddy
Joined: 24 Jun 2007 Posts: 14
|
|
Posted: Tue Jul 31, 2007 4:53 pm |
|
|
Thank you!!!!! I didn't realise I could manually turn of the xmit. You have saved my day! |
|
|
caddy
Joined: 24 Jun 2007 Posts: 14
|
|
Posted: Wed Aug 01, 2007 4:07 am |
|
|
Alas... I had sent the previous message while I was at work so unable to test it until now.
Unfortunately, when I disable the xmit pin, I still cannot use the PIN_C6 as an output pin.
The chip is an 18F2525.. is there any reason why PIN_C6 *must* be specified as the xmit pin?? I am lost...
Thanks |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Aug 01, 2007 7:12 am |
|
|
If you don't specify C6 for Xmit the compiler will use a software UART. When you say you cannot use the PIN_C6 as an output pin, do you mean the compiler generates an error, or the pin is stuck high or low?
What is your compiler version? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
caddy
Joined: 24 Jun 2007 Posts: 14
|
|
Posted: Wed Aug 01, 2007 4:25 pm |
|
|
SherpaDoug wrote: | If you don't specify C6 for Xmit the compiler will use a software UART. When you say you cannot use the PIN_C6 as an output pin, do you mean the compiler generates an error, or the pin is stuck high or low?
What is your compiler version? |
Hi SherpaDoug
When I say I can't use PIN_C6 as an output pin, I mean that it is stuck high or low (I didn't check which) and will not respond to output_high/output_low. The compiler doesn't generate an error..
I will have to check my compiler version when I get home (at work at the moment)..
Any ideas?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 01, 2007 9:55 pm |
|
|
I tried it on an 18F452 with PCH vs. 4.047, on a PicDem2-Plus board and
it didn't work. The data sheet shows the pin drivers for the UART
are controlled by SPEN, not TXEN. (There's a block diagram in the UART
section that shows this). But if you turn off SPEN, you turn off the whole
UART, so using that bit instead of TXEN won't help. |
|
|
caddy
Joined: 24 Jun 2007 Posts: 14
|
|
Posted: Wed Aug 01, 2007 11:03 pm |
|
|
PCM programmer wrote: | I tried it on an 18F452 with PCH vs. 4.047, on a PicDem2-Plus board and
it didn't work. The data sheet shows the pin drivers for the UART
are controlled by SPEN, not TXEN. (There's a block diagram in the UART
section that shows this). But if you turn off SPEN, you turn off the whole
UART, so using that bit instead of TXEN won't help. |
Thanks for trying it out PCM programmer.
Hmm, I guess it just isn't possible to do this. I'll have to work around this problem I guess..
Thanks for the help everyone! |
|
|
|