PAUL James wrote: > And that's exactly the point. If this works and it takes longer to see > an error, > then it follows that the timing is the culprit, and means can be taken > to correct that problem. > > Jim > > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of Jinx > Sent: Friday, January 12, 2007 5:00 PM > To: Microcontroller discussion list - Public. > Subject: Re: [EE] Very odd problem with RS232... > > > >> You may be getting out of sync with the PIC and the PC if the >> frequency is off by more than a few percent. Try lowering the >> baud rate on both the PC And your PIC board, and see if that makes any >> > > >> difference >> > > Lowering the baud rate will just make errors take longer to happen. > If it is a timing problem, the PIC clock needs to be changed to match > the baud rate from the PC > One can "measure" the RC PIC's baud rate by timing the width of the start bit. This is VERY easy to do if a software UART is being used. I simply set the T0 interrupt to a short interval and count the total number of interrupts received. If the count is too high, the PC-generated start bit is perceived to be too slow (so the receiving PIC clock is running too FAST, so OSCTUNE must be increased); if the count is too low, the PC-generated start bit is perceived to be too fast (so the receiving PIC clock is running too SLOW, so OSCTUNE must be decreased). Be sure to wait for a few mS while the new OSCTUNE value takes effect, otherwise you will simply bounce up and down endlessly. Normally you will discover the best value within 5 tries. I write my serial interfaces to allow the RC-driven PIC to measure the start bits of several bytes before I reply to any of the packets. This works well to synchronize two RC-driven PICs, too, but ONLY ONE should be allowed to correct itself. --Bob > Sam, are you going through an RS232 i/f (eg MAX232) ? > > -- > http://www.piclist.com PIC/SX FAQ & list archive View/change your > membership options at http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist