View previous topic :: View next topic |
Author |
Message |
iw2nzm
Joined: 23 Feb 2007 Posts: 55
|
Serial repeater: garbage chars |
Posted: Thu Jun 21, 2007 8:20 am |
|
|
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
|
|
Posted: Thu Jun 21, 2007 8:59 am |
|
|
You may need to invert the output. Something similar happened ot me and the inversion worked. |
|
|
Ttelmah Guest
|
|
Posted: Thu Jun 21, 2007 2:09 pm |
|
|
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
|
|
Posted: Sat Jun 23, 2007 1:23 am |
|
|
Thanks to both... I'll try your tips in the next week because yesterday morning my ICD2 was broken. |
|
|
|