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

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: 56

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: 6251
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: 56

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: 13536

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: 56

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