Hi Joep, Vasile,
Joep Suijs wrote:
A serial char consists of a start bit (0), 8 databits with the lsb
first (0x78 = 0001 1110) and a stop bit (1) so: 0 0001 1110 1 If we
get out of sync (with a framing error?), the four '1's are considered
idle, Taking the next 0 as a startbit we get 0 1000 0111 1, which is
the 1E you see. So what happens? The transmit baudrate is actually
too low and chars are sent at maximum speed, at some time the
transmitter will get a bit behind on the intended (receiver) timing.
At that point, no valid stop bit will be detected, giving a framing
error. Then the receiver will listen for the next start bit (0) and
receive from that point on. I'd say this behavior is inevitable when
sending continuously when the baudrates are not exactly the same. So
I don't know why other pics and other baudrates don't suffer from
this issue. If my theory is correct, the issue could be fixed by
using 2 stopbits at the sending side.
This matches my suspicion about the bit-shifting. I forgot to say that
when this occurs also a few characters were not echoed.
And indeed with 2 stopbits (from PC to PIC) the echo is perfect!
Drawback is that it slows down the effective transmission speed by about
10 percent, but I'm afraid this is the price for perfect transmission.
With this experience I might consider to let my TinyBootloader support
program and Xwisp2 use 2 stopbits in stead of currently 1.
The reason that I don't see the problem with a 16f886 could be a better
USART module. In the datasheet of the 16F887A I read in section 10.1.1
that data is sampled 3 times (per bit time), while in the datasheet of
the 16F886 section 12.1.2 I think they are saying 16 samples per bit. If
that is true I'm not surprised it works better, even with deviations of
the baudrate.
You didn't react on the following.
BTW. Newer PICs have EUSARTs, which alow a more accurate baudrate
setting. Would be nice if the serial libraries could use these!
Seems to me not too complicated to implement. But is no solution of
the 16f877a of course.
Any chance you'll implement this in the baudrate calculation procedure?
Vasile,
oscillator or resonator?
Resonator. And I must add: I tested the 17f877a and 16f886 on different
boards. Both with a 16 MHz resonator, but not the same. So that may also
be the cause of different observations.
I could repeat the tests with a 16F873[A] which is a close relative to
the 16F877A on the 16F886 board. This will be a better comparison (less
differences).
A low Q factor for the resonator (which is quite common) may cause
variable amplitude in the OSCOUT pin. Take a look with a good scope
and see if you have enough amplitude above the trigger point. If not,
the cause may be but the gaps in the oscillation.
I'm afraid the old scope I have here (Tektronix 453) may not be good
enough for this purpose.
Are you reading the chars from the buffer or directly from the RCREG?
I had some similar problems untill I didn't use the buffer from the
serial-hw_int_cts library. The chars where shifted when moved in the
buffer.
Of course(!) I'm reading from the buffer (which is reading RCREG for
me)! I have used this library (and a similar implementation in
C-language) for years for different projects and have never experienced
a character shift problem. We have discussed this before and I still
think you are not using the library the way it is intended. But if you
are convinced there is a problem with this library, please open an Issue
in Jallib at GoogleCode and provide evidence of your bad experience.
Then it will be more open than between you and me and other people may
help to solve the problem.
Anyway, character-shifting is different than bit-shifting.
Regards, Rob.
--
Rob Hamerling, Vianen, NL (http://www.robh.nl/)
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.