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

12F1840 using serial port for indication question

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



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

12F1840 using serial port for indication question
PostPosted: Sat Feb 11, 2017 7:45 am     Reply with quote

Hi all,

pic - 12F1840
ccs compiler ver: 4.141
I have a project here and the program has 2 modes of operation. Run mode and configure mode. when in configure mode i am using the rs232 port pin A4 and PIN A5 for serial comm.
I have connected a led to pin A4. its working fine in config mode. but in run mode i am using the led as indication. but when i turn the pin to low to light up led it always stays in 5V and does not work. i have tried using PIN A5 and it works in run mode but does not work in config mode ie when i configure it as output_low it screws up the rs232 communication.

any advice would be helpful and thanks.
temtronic



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

View user's profile Send private message

PostPosted: Sat Feb 11, 2017 8:02 am     Reply with quote

We need to see your code ! A schematic would be nice too.
Odds are you have not configured the PIC properly for RA5 to be an output. There are several internal peripherals 'attached' to that pin and all must be disabled. If you've used a 'wizard' to setup the PIC be warned 'wizards' are not 'all powerful' and can/do default pins to what they think they should be.

Your last sentence says you have BOTH RS232 rcv AND an LED attached to that pin,not a good idea, but it could be made to work. Same holds true for RA4( RS232 xmt).
It sounds like you've run out of pins ! If so, either upgrade to a larger PIC or get 'clever' with your code and 'mux' the pins.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat Feb 11, 2017 12:32 pm     Reply with quote

You do realise that a serial port line idles high.

You need to disable the UART if you want to drive the pins for other purposes.

Use the option in the #USE RS232, 'NOINIT'. Then when you want to use the UART, call "setup_UART(baud_rate);" with the rate you want to use. When you don't want the UART, use "setup_UART(FALSE);", and the pins can then be used for other things.
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

PostPosted: Sat Feb 11, 2017 1:01 pm     Reply with quote

Thanks Ttelmah for your help, its working now. Thanks temtronic.
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