View previous topic :: View next topic |
Author |
Message |
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
12F1840 using serial port for indication question |
Posted: Sat Feb 11, 2017 7:45 am |
|
|
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
|
|
Posted: Sat Feb 11, 2017 8:02 am |
|
|
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
|
|
Posted: Sat Feb 11, 2017 12:32 pm |
|
|
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
|
|
Posted: Sat Feb 11, 2017 1:01 pm |
|
|
Thanks Ttelmah for your help, its working now. Thanks temtronic. |
|
|
|