usart.write loosing characters

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
james5017
Posts: 1
Joined: Wed Sep 24, 2008 3:31 pm
Location: Cambridge, ON Canada

usart.write loosing characters

Post by james5017 » Wed Sep 24, 2008 4:06 pm

Hi,

I'm new to SF and have been evaluating the SE edition. I've started out by running the sample programs provided in the download. using the "TextAndNumbers.bas" example from the Samples/Usart directory, I have the following problems:

1. The last usart.write statement does not send the last two characters (in this case, the CR LF pair. I have checked this in three different terminal programs with the same result. I have simplified this to a single statement:

usart.write("abcd")

The terminal receives only ab

2. Immediately after programing the sample program runs and sends the output twice. (same both times). However, after pressing reset the program sends the output only once as expected (but with the last two characters missing).

Environment:
Windows XP SP2, Standard serial comport (com2) br19200
18F452 in MELabs Lab X1 board, clock 20
EPIC programmer

Any help appreciated
Jerry

User avatar
JWinters
Posts: 106
Joined: Mon Feb 04, 2008 4:56 pm
Location: North Carolina, USA
Contact:

Post by JWinters » Wed Sep 24, 2008 7:35 pm

Do you have the Watchdog Timer disabled?

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Wed Sep 24, 2008 8:33 pm

It might be that your program ends and the PIC goes to sleep after you have sent the text. The string is sent to the buffer, but the PIC goes to sleep before the last two bytes have been sent from the buffer of the USART module. Try adding the following at the end of your program to keep the PIC awake:

Code: Select all

While True
Wend

Post Reply