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

Enable & Disable RS232 at runtime

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



Joined: 13 Jan 2012
Posts: 2

View user's profile Send private message

Enable & Disable RS232 at runtime
PostPosted: Fri Jan 13, 2012 8:06 pm     Reply with quote

Hi, this is my first post, I have a project using 16f1824, i want to enable the RS232 when PIN_A5 is high, and disable when its low, but i don't know how to disable the rs232.

Any ideas???
_________________
Diego
Ttelmah



Joined: 11 Mar 2010
Posts: 19278

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 3:03 am     Reply with quote

One has to ask what you mean by 'disable'?.
At the end of the day, if you don't send anything, the RS232 sits doing nothing. So, just stop sending....
However if you means you want to use the pins for something else, then use the baud=0 option.
If you have your #use RS232 set baud=0, everything is setup ready to go, but the UART is turned off. Then just use 'setup_uart(baud_rate_you_want);', to start using the UART, and when you have finished, use 'setup_UART(FALSE);' to turn it off again.

Best Wishes
Diego1974



Joined: 13 Jan 2012
Posts: 2

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 7:53 am     Reply with quote

Thank you Ttelmah, thats exactly what i'm trying to do, use in some part of the program the RS232 pins, and in another part to do something else, so thank you for your support. I will make some test and i will post the results.

Regards,
_________________
Diego
temtronic



Joined: 01 Jul 2010
Posts: 9142
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 8:30 am     Reply with quote

One problem you may have concerns the device on the other end of the RS232 pins. When you use them for 'the other action', you'll also send data to the other device. Depending on that devices program you could lock up it's UART or send bad data to it.
Just something to watch out for.
mfeinstein



Joined: 05 Jul 2012
Posts: 35

View user's profile Send private message

PostPosted: Thu Mar 21, 2013 9:32 pm     Reply with quote

I am using a PIC18F2550 and this only works for me if I call a 'setup_uart(1);' after a 'setup_uart(0);'.
If I try like Ttelmah said, just placing a 'setup_uart(baud_rate_you_want);' it never turns one again and the PIC freezes forever.
temtronic



Joined: 01 Jul 2010
Posts: 9142
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 22, 2013 5:46 am     Reply with quote

without seeing your code it's impossible to say why it 'freezes' but perhaps you have an interrupt enabled without a handler?
or a sunset loop?


hth
jay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Mar 22, 2013 6:08 am     Reply with quote

caveat creator :
re-purposing the TX pin in runtime, w/o a hardware GATE for your TX destination is a surefire way to get into trouble.

RX , not so much
Ttelmah



Joined: 11 Mar 2010
Posts: 19278

View user's profile Send private message

PostPosted: Fri Mar 22, 2013 6:16 am     Reply with quote

It'll behave like this if you try to set a baud rate on a _software_ UART. Are you sure you are using the hardware UART?...

Best Wishes
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