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

2 serial rs-232 port at the same time

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



Joined: 01 Feb 2006
Posts: 5

View user's profile Send private message

2 serial rs-232 port at the same time
PostPosted: Wed Feb 08, 2006 8:44 am     Reply with quote

Hi,

I'm using a PIC18F1320 in my design and want to use Hardware and software USART at the same time. The hardware USART is connected to a PC and the Software USART is connected to a Dallas one wire line driver.

I saw in the CCS manual that you can use #use rs232 command to set the RS232 ports. Does anybody have a source code to use the built in USART and use portB to drive a software USART at the same time.

Thank's
Maverick72



Joined: 01 Feb 2006
Posts: 5

View user's profile Send private message

PostPosted: Wed Feb 08, 2006 8:45 am     Reply with quote

I forgot to say that the hardware USART connects to PC trough a MAX232
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 12:38 pm     Reply with quote

Here is some simple code to get you started.
Code:
#include <18F1320.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B1, rcv=PIN_B4, ERRORS, stream=HW_UART)
#use rs232(baud=9600, xmit=PIN_B0, rcv=PIN_B2, stream=SOFT_UART)

void main(void)
{
char c;

setup_adc_ports(NO_ANALOGS);

fprintf(HW_UART, "Start\n\r");  // Send to hardware UART

c = fgetc(HW_UART);  // Get char from hardware UART

fputc(c, SOFT_UART);  // Transmit it with software UART

while(1);  // Don't let PIC go to sleep
}
Maverick72



Joined: 01 Feb 2006
Posts: 5

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 1:53 pm     Reply with quote

Thank's

I already figured it out yesterday. At first I tried with the RX pin on port A and the TX pin on port B. Could that have been the reason why it didn't work ?
Maverick72



Joined: 01 Feb 2006
Posts: 5

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 1:54 pm     Reply with quote

Forgot to say that i configured those pin for the software UART
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 09, 2006 2:24 pm     Reply with quote

I can't know for sure, unless you specify the exact pin.
The pins on Port A can have many functions. They can
be analog, or LVDIN, MLCR, oscillator, or digital i/o.
Also RA5 is input only, and RA4 is open-drain.
(it can't drive high. It requires a pullup resistor)
You must have a digital output pin for Tx and a digital
input pin for Rx.

So there could be many reasons why your soft UART
didn't work on Port A.

Remember, the Microchip designers try to cram as many
features as possible onto each pin and you have to choose
a pin that will work, and you have to configure it for digital i/o.
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