CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Possible to not specify xmit pin in #USE RS232 statement?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
caddy



Joined: 24 Jun 2007
Posts: 14

View user's profile Send private message

Possible to not specify xmit pin in #USE RS232 statement?
PostPosted: Tue Jul 31, 2007 7:19 am     Reply with quote

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







PostPosted: Tue Jul 31, 2007 7:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 31, 2007 4:53 pm     Reply with quote

Thank you!!!!! I didn't realise I could manually turn of the xmit. You have saved my day! Smile
caddy



Joined: 24 Jun 2007
Posts: 14

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 4:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 7:12 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 4:25 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 9:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 01, 2007 11:03 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group