Hi Rob, My theory: 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.
Joep 2010/1/19 Rob Hamerling <[email protected]>: > > Hi Joep, > >>> 2010/1/19 Rob Hamerling <[email protected]>: >>> With 20 MHz serial comms is no problem at 115200 bps, but with >>> 16MHz I get sometimes garbled data. When my calculations are correct (and >>> the 16MHZ resonator is really 16MHz) this is with a baud deviation of >>> 3.6 >>> percent, while the library has an error limit of 5%. > > > [Joep] >> >> Interesting... Theoretical baudrate deviations close to -10% should be >> possible iirc, so 5%should be safe. However, if transmission speed is >> higher then receiving speed and transmission is continues, garbage can >> occure. So I'm interested what happens. Are there overruns? Is the >> baudrate divisor calculated correctly? > > I don't know if there are overruns, these are hidden by the library. But > that would result in missing characters in the echo: none! > The baudrate divisor is correct (SPBRG is loaded with 8). > >> Has it to do with you specific host (probably not)? >> I think we need to know what happens, before we decide to reduce the >> tolerance allowed. Adding a warning may be wise though. > > The data garbling occurs when sending a burst of data, typically a few > hundred of the same character to a 16F877a which only task is to echo the > incoming data one-to-one at 115200 bps. The program uses the > serial-hw_int_cts library CTS handling active. On the PC side I use a > relatively simple terminal program, 8 databits, 1 stopbit, no parity, serial > port FiFo transmit buffer active (16 bytes), CTS output flow control > enabled. > > The garbling has a pattern! When I send a large number of 'x' chars the > first part comes back as 'x' (0x78), but is then followed by a burst of 0xE1 > chars. When you look at the bit pattern (put a number of 0x78 and 0xE1 after > each other) the bits are shifted two positions (as if the 16f877a missed 2 > databits). Later a series of another character is echoed (could also be 'x' > !). Two different 16f877A, same results. > It doesn't look to me like caused by a baudrate mismatch, but what else? > > I've just done a similar test with a 16f886 also at 16MHz oscillator and > also everything else the same: no problem. > > So it seems it's an issue with the 16f887A. > > I would like to do the same tests with a 20 MHz resonator, but I have > currently no 40-pins test board with 20 MHz oscillator and serial interface, > and don't want to (re)solder resonators. > > > 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. > > 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. > > > >
-- 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.
