If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
I've got a PIC16F747 and have enabled the UART module for talking to my PC.
It works great, except for if I exceed ~5 bytes back to back, at which point the receipt becomes unreliable - the received message is often incomplete or contains errors. I'm using 9600baud, no parity, and the baud rate error is low (0.16%).
My question: Am I obliged to enforce a delay between bytes in my code?
Registered Member #27
Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
You do not need any pause between bytes, after receiving the required number of bits the receiving UART will look for a valid start bit/stop bit sequence to find the next byte.
There is a slight problem that if your data is noisy it may mistake the start of a byte and if you have no pause your data may have data that have the same transitions as the start bit/stop bit sequence. In that case it may not recover. So for the most reliable transmission you should have pause between bytes or send small packets with pause between. Then you are guaranteed that it will recover.
PC UARTs in general are very forgiving and will correctly receive even if the link is far outside specification.
The symptoms sounds quite like classical buffer overflow which can happen at either end and at any burst length or speed depending on the configrations and software at both ends.
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
Thanks Bjorn.
This portion of my application reports the values of 5 of the onboard ADC's via RS232. I changed the code so that rather than doing all 5 conversions and then sending the results all at once, it sends the data (4 bytes including my own spacing characters) immediately after each conversion finishes.
Its better, but not perfect. What do you suppose a good delay would be?
Second question - even when the link operates properly, sometimes the ADC's jump around (mostly when a source is not connected). I'm pulling them down with 33ks, should I be using a stronger pull-down?
I had a similar problem that i somehow fixed by adding the #ERRORS tag (using CCS), you could maybes try that, although i did also introduce a delay between packets in the end.
Registered Member #1232
Joined: Wed Jan 16 2008, 10:53PM
Location: Doon tha Toon!
Posts: 881
You are checking that the UART's transmit register is clear before trying to send another character?
It takes a finite amount of time to serially clock out a character when the UART is transmitting. You need to ensure that each byte has been fully transmitted before you try to ram another value into the transmit holding register. If you try to send another character before the UART has flagged that it is ready, it will either result in dropped characters or corrupted characters. I forget which one happens with PICs.
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
GeordieBoy wrote ...
You are checking that the UART's transmit register is clear before trying to send another character?
It takes a finite amount of time to serially clock out a character when the UART is transmitting. You need to ensure that each byte has been fully transmitted before you try to ram another value into the transmit holding register. If you try to send another character before the UART has flagged that it is ready, it will either result in dropped characters or corrupted characters. I forget which one happens with PICs.
-Richie,
Yes. I move a character for sending into the w register and the call my sending function, which does not return until the send is complete. For scrutiny:
;*** Send character
send call errchk
movwf TXREG ; send data in W
TransWt bsf STATUS, RP0 ; RAM PAGE 1
WtHere btfss TXSTA, TRMT ; (1) transmission is complete if hi
goto WtHere
bcf STATUS, RP0 ; RAM PAGE 0
return
;*** Error check
errchk btfss RCSTA, OERR
goto errdone
bcf RCSTA, CREN ; reset USART RX logic, clear RCSTA,OERR
bcf RCSTA, FERR ; reset framing error bit
bsf RCSTA, CREN ; re-enable continuous reception
errdone return
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.