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

Share RS232 pins with LED status pins using software UART?

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



Joined: 07 Jul 2006
Posts: 9
Location: US

View user's profile Send private message

Share RS232 pins with LED status pins using software UART?
PostPosted: Mon Apr 17, 2017 9:20 am     Reply with quote

I want to share RS232 pins with LED's on an 8-pin chip without hardware UART. Detailed description of what I'm trying to accomplish below. How do I use the RS232 pins for serial communications, then disable the software UART and use the same two pins to control LED's. Looks like "setup_uart(0)" is exactly what I need but manual states "This function is only available on devices with a built in UART" and I'm using software UART. Would USE RS232() FLOAT_HIGH or NOINIY work for my needs? If so please explain or an example program would be great. The manual does not explain clearly the differences between HW and software UART usage. My current need is to disable and never re-enable the software UART, but it would be good to also know how to re-enable it as well.

My goal is to have user configurable parameters that will store in internal EEPROM. This will probably be a one time configuration for the user, and rarely need change again if ever. At chip power on I will display a menu over RS232 and wait for some character, probably a "*" or something. If I receive the character over RS232 then the program will prompt for parameters and update configuration setting in the EEPROM. If nothing is received over RS232 within say 5 seconds the RS232 will be disabled and the program run as normal displaying status on the LED's. Normally nothing will be attached to the RS232/LED pins except the LED's, the user will have to manually attach a TTL level converter or move jumpers to connect a RS232/TTL level converter chip to the PIC. If I end up with a free pin I may use a jumper to put the chip into configuration mode, but either way I need to share the RS232 and LED pins. Chip I'm planning on using is an older PIC12F683, because I have a lot of them on hand.

I have searched but have not found an answer, sorry if this has already been answered and I missed it.
jeremiah



Joined: 20 Jul 2010
Posts: 1353

View user's profile Send private message

PostPosted: Mon Apr 17, 2017 3:11 pm     Reply with quote

I may be confused about what you are asking, but why not simply use output_high() or output_low() on the pins you have for the LED's when you are finished using the UART? A software UART isn't a peripheral, it's just logic driving IO's, so when you aren't calling UART functions, it doesn't control the pins. If it were a hardware UART where a peripheral had control of the pins, then you would need to do something special, such as disable the UART. With software UARTs there is nothing to disable.

Code:

call_some_function_that_does_sw_uart_stuff();
//now done with the UART
output_low(YOUR_TX_PIN);  //set your LED state


Am I misunderstanding?
Stuffed-Bit



Joined: 07 Jul 2006
Posts: 9
Location: US

View user's profile Send private message

PostPosted: Thu Apr 20, 2017 10:50 pm     Reply with quote

jeremiah wrote:
Am I misunderstanding?


Nope, you were correct. I set this up and tested and it works exactly like you said. From reading I was under the impression that once the compiler configured the serial pins it kept control of them. Guess that is more of how the compiler works with the hardware UART.

Anyway, thanks for the reply and verify how the software UART works.
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