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

How to test multiple software uart on only 1 PIC chip

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



Joined: 28 Jan 2006
Posts: 1

View user's profile Send private message

How to test multiple software uart on only 1 PIC chip
PostPosted: Sat Jan 28, 2006 1:35 am     Reply with quote

Dear all,
I have been trying to use multiple software UART on pic18f458 without success. Using 1 pic chip, I physically wired pin B0 to pin A0. Are there any way to test multiple software UART for 1 pic properly.

I appreciate any help.

Here is my code.
#include <18F458.h>
#device adc=8
#use delay(clock=40000000)
#fuses NOWDT,WDT128,H4, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOCPB, NOWRTC, NOEBTR, NOEBTRB
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,stream=PC)
#use rs232(baud=9600,xmit=pin_a1,rcv=pin_a0,stream=com1)
#use rs232(baud=9600,invert,xmit=pin_b0,rcv=pin_b1,stream=com2)

unsigned char data;


void main()
{


fprintf(PC,"welcome \r\n");
while(1)
{

fprintf(com2,"C"); // try to send data to port A
delay_ms(50);
data = fgetc(com1); //try to get data from port B

fprintf(PC,"value is %c \r\n",data); //send data to pc's serial port
//fputc(ch[0],PC);
delay_ms(300);


}


}

Andy O
King Virus



Joined: 02 Mar 2006
Posts: 14
Location: Italy

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Mar 05, 2006 3:57 am     Reply with quote

Please post me a schematic of you wiring...

Do you use a MAX232 (Levelshifter) or someting else ?
If you don�t you have to invert the signal with some transistors...
_________________
*** A good forum is a forum where people respect eatch other ! ***
SteveL
Guest







PostPosted: Sun Mar 05, 2006 5:29 am     Reply with quote

You have to understand the limitations of the software serial ports.
These are, as the name suggests, implemented by code that CCS generate for you, so you have to remember that while you're sending something from a software serial port, the PIC is tied up while it drives the output pin high and low with the appropriate timings. Only when it's finished sending does 'your' code continue.
Similarly when receiving, the PIC sits waiting for the character to arrive & samples the input pin with the appropriate timing only when this has fiished does 'your' code continue.

So, what you're doing in your code is transmitting from one software port, and then when this has finished you wait 50mS then start listening.
So the transmitted data has finished way before you start to listen for it.

What you're trying to do can be achieved, but you need to manually, rather than use the CCS code, handle the output pin driving and the input pin changing. This is usually done by setting up a timer interrupt at a fast enough rate for the serial baud rate and putting your software serial port code in the interrupt.

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