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

Serial repeater: garbage chars

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



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

Serial repeater: garbage chars
PostPosted: Thu Jun 21, 2007 8:20 am     Reply with quote

Hello!

In my application there are 2 serials, both 9600 8N1. The first is connected to the hw uart of a PIC18F4520 running at 6 MHz, the second to a sw uart. I have to repeat the incoming strings from port1 to port2.

Each string has a length of about 40-50 chars and is terminated by a CR control char. So I use this simple code into the RDA interrupt routine:

Code:

char text[64];

fgets(text, PORT1);
fputs(text, PORT2);


Port2 transmits a lot of garbage chars. However if I set the port1 at very low speed (300 baud) all works fine.
I tried also to repeat char by char using fgetc and fputc but without success.

What's the best way to achieve the goal?

Thanks
Marco / iw2nzm
Guest








PostPosted: Thu Jun 21, 2007 8:59 am     Reply with quote

You may need to invert the output. Something similar happened ot me and the inversion worked.
Ttelmah
Guest







PostPosted: Thu Jun 21, 2007 2:09 pm     Reply with quote

The garbage characters, are almost certainly because the software serial is being 'interrupted' by something else (probably the receive). If the rates are the same or slower on the incoming data, then try adding 'disable_ints' to the software RS232 declaration.

Best Wishes
iw2nzm



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Sat Jun 23, 2007 1:23 am     Reply with quote

Thanks to both... I'll try your tips in the next week because yesterday morning my ICD2 was broken. Mad
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