PDA

View Full Version : Serial Communications: Effect of Propeller Clock Speed on Baud Rate



Sal Ammoniac
05-31-2010, 01:39 AM
Has anyone done any characterization of the maximum serial baud rates supported by the FullDuplexSerial object at various Propeller clock rates?

I did a quick analysis of the FullDuplexSerial code and concluded that it would support 9600 baud when running the Propeller at 5MHz (_CLKMODE = XTAL1 + PLL1X, _XINFREQ = 5_000_000).

I have an application running on a Propeller that uses FullDuplexSerial to send data, but not receive anything. After running everything at these rates for several weeks, I've noticed that at random intervals the Propeller starts dropping characters and sending random junk on the serial line. After a period of time that varies from minutes to hours, the serial stream returns to normal. I'm thinking that the serial timing at 9600 baud on a 5MHz Propeller is right on the hairy edge and occasionally drifts out of spec and transmits random crap.

(I'm running the Propeller at 5MHz to conserve power as this application is battery powered.)

Mike G
05-31-2010, 02:12 AM
At 5Mhz you can run about 130 PASM instructions per 9600 bps clock tick. There's 41 instructions in the entire transmit routine. I'm sure someone will correct me if I'm mistaken, but you're far from the hairy edge. You might want to look else where for the source of the problem.

Post Edited (Mike G) : 5/30/2010 6:56:42 PM GMT

Mike Green
05-31-2010, 02:26 AM
FullDuplexSerial has been tested at well in excess of 230KBps with an 80MHz system clock. With a 5MHz system clock, you'd have a "top end" on the order of 15KBps, well over 9600 Baud.

Sal Ammoniac
05-31-2010, 04:34 AM
Well, then it seems like something else is going on. I can duplicate this with code as simple as




CON

_CLKMODE = XTAL1 + PLL1X
_XINFREQ = 5_000_000

OBJ

Serial : "FullDuplexSerial"

PUB Main

Serial.start(6,7, 0, 9600)

repeat
Serial.str(string("Now is the time for all good men to come to the aid of their country..."))
waitcnt(clkfreq + cnt)




Hardware is: Propeller running at 5 MHz, MAX3232 to generate RS-232 on Propeller end. The PC end is a Parallax serial-to-USB converter plugged into a 3GHz PC running WinXp and displaying the serial stream via Hyperterminal. The serial cable is ~6 feet long.

Mike G
05-31-2010, 04:47 AM
I verified that your code works fine on a Prop Demo board. I'm reading the serial data with the Parallax Serial Terminal.

Only difference is..


Serial.start(31, 30, 0, 9600)

JonnyMac
05-31-2010, 04:58 AM
If cog resources are not an issue you can create separate RX and TX cogs; this simplification allows for greater speeds than a single cog doing both.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Sal Ammoniac
05-31-2010, 05:36 AM
In fact, my application doesn't use serial RX at all, so I'll edit FullDuplexSerial and remove the receive code entirely. But, as someone mentioned above, this object should support 9600 baud easily at 5MHz, so removing the RX code should not have any effect.

I'll let my testbed setup run until it starts sending garbage again and then scope the Propeller port used for TX data and see what it's actually sending.

JonnyMac
05-31-2010, 05:59 AM
I've attached my dirt-simple tx object -- it may save you some time.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA