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 CCS Technical Support

reassign Tx on #use rs232 as general purpose IO? [SOLVED]

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



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

reassign Tx on #use rs232 as general purpose IO? [SOLVED]
PostPosted: Tue Apr 17, 2018 1:22 pm     Reply with quote

Hello,

I'm not using the TX pin on my UART module. Can I reassign that for general IO usage? Right now I'm just trying to do the output_low() function but it's just always staying high.

Joel


Last edited by picj1984 on Fri May 04, 2018 3:40 pm; edited 1 time in total
temtronic



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

View user's profile Send private message

PostPosted: Tue Apr 17, 2018 1:47 pm     Reply with quote

yes, you should be able to, but you need to post which PIC and compiler version , so that others can test to confirm .
It could be a simple premade function or you may have to code yourself, that's why compiler version is nice to know.
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Tue Apr 17, 2018 2:28 pm     Reply with quote

temtronic wrote:
yes, you should be able to, but you need to post which PIC and compiler version , so that others can test to confirm .
It could be a simple premade function or you may have to code yourself, that's why compiler version is nice to know.


oops sorry about that. It's a PIC16F1825 and I'm using PCM Compiler V4.140.
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Wed Apr 18, 2018 12:41 am     Reply with quote

You have to do a little bit more fiddling. Thing is that for the code to use the hardware UART it has to be told to use _both_ pins. This then leaves the TX pni being driven by the UART. So the key is to turn this off:
Code:

//Processor include
//fuses
//clock declaration

#use RS232(UART1, BAUD=9600, ERRORS)
//Standard UART enable on the default hardware pins

//Then
#BIT TXEN=getenv("BIT:TXEN")
//This now gives us access to the UART TXEN bit

void main(void)
{
    TXEN=FALSE; //Turn off the UART transmit
    //You can now read and write the TX pin normally

   while(TRUE)
      ;
}


As you can see it is very easy. All you do is enable the UART normally, and then turn off the transmit 'side' of the hardware.
picj1984



Joined: 01 Mar 2010
Posts: 73

View user's profile Send private message

PostPosted: Fri May 04, 2018 3:41 pm     Reply with quote

Ttelmah wrote:
You have to do a little bit more fiddling. Thing is that for the code to use the hardware UART it has to be told to use _both_ pins. This then leaves the TX pni being driven by the UART. So the key is to turn this off:
Code:

//Processor include
//fuses
//clock declaration

#use RS232(UART1, BAUD=9600, ERRORS)
//Standard UART enable on the default hardware pins

//Then
#BIT TXEN=getenv("BIT:TXEN")
//This now gives us access to the UART TXEN bit

void main(void)
{
    TXEN=FALSE; //Turn off the UART transmit
    //You can now read and write the TX pin normally

   while(TRUE)
      ;
}


As you can see it is very easy. All you do is enable the UART normally, and then turn off the transmit 'side' of the hardware.


Just realized I never came back to say "thanks!" this is working for me now Smile
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

rs232 on/off
PostPosted: Mon Nov 28, 2022 5:09 am     Reply with quote

I know this topic is very old but I want to thank you Ttelmah for explaining how to enable/disable the TX pin

Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Mon Nov 28, 2022 8:04 am     Reply with quote

Well done that you found this. Very Happy

99% of things like this have been answered here, which is why using the
search is such a powerful tool.
For some answers things have later 'evolved'. So (for example) there are
threads a few years ago on how to manually set ANSEL, which have now
been made redundant with CCS adding this to set_adc_ports). However
most of the answers still apply as they did when originally made.

Glad you have it doing what you want.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 28, 2022 9:21 am     Reply with quote

Definitely the forum search is one of the best tools available.
You spend some time, but you save much much more Very Happy

Best wishes
Joe
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