View previous topic :: View next topic |
Author |
Message |
stma
Joined: 16 Feb 2004 Posts: 26
|
Serial Data Corruption |
Posted: Mon Oct 30, 2006 9:21 am |
|
|
Hi,
I am using a PIC16LF876 and have a program which does various functions.
(would post code but it is rather long)
Anyway, I use serial data outputs (using PRINTF) to display information on the PC via a terminal program. This has all been working fine until I recently added code to the program to increase its functionality. Now whenever I write to the screen it is corrupt. (looks like it would when the incorrect Baud rate is selected, but this is not the case).
The (shorter) program works fine but the added codes creates this problem.
even just doing a simple PRINTF which is in no way connected to the rest of the program is corrupt.
Any ideas??
Thanks
Steve |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Oct 30, 2006 12:20 pm |
|
|
Yes.... you broke it when you added 'functionality.' (OK, so you've probably already figured that out.) Since one of the pros hasn't answered up, there probably isn't a quick, obvious fix.
First, go back to your old code and confirm the hardware is still working.
Second, slowly add your new code and test after each addition or add it all and start commenting out as much of your 'added functionality' as you can to see if you can get it working again. The only thing you can do is isolate the offending code (if that's what it is) and locate it that way.
Good luck,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 30, 2006 1:32 pm |
|
|
Quote: |
I use serial data outputs (using PRINTF) to display information on the PC
via a terminal program. This has all been working fine until I recently
added code to the program to increase its functionality. Now whenever
I write to the screen it is corrupt. |
This could happen if you're using a software UART and you enable
interrupts for some other device (such as a timer, or external interupts,
etc.). The interrupt will disrupt the timing of the pulses in the software
UART.
Example: Add the parameter shown in bold below.
Quote: | #use rs232(baud=9600, xmit=PIN_B1, rcv=PIN_B0, DISABLE_INTS) |
|
|
|
stma
Joined: 16 Feb 2004 Posts: 26
|
|
Posted: Tue Oct 31, 2006 2:21 am |
|
|
Thanks for the replies.
I will have a look at the code.
Interesting thing this morning. The program correctly receives data from the keyboard (PC) and always has done.
I changed my terminal settings to have ODD or EVEN Parity and hey presto it works as normal (previously using 8N1)
Haven't a clue why this is. If anyone could shed light on it it would be interesting to find out why this occurs.
Thanks
Steve |
|
|
|