Shop OBEX P1 Docs P2 Docs Learn Events
Serial Communications: Effect of Propeller Clock Speed on Baud Rate — Parallax Forums

Serial Communications: Effect of Propeller Clock Speed on Baud Rate

Sal AmmoniacSal Ammoniac Posts: 213
edited 2010-05-30 21:59 in Propeller 1
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 Smile.

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

Comments

  • Mike GMike G Posts: 2,702
    edited 2010-05-30 18:12
    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 GreenMike Green Posts: 23,101
    edited 2010-05-30 18:26
    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 AmmoniacSal Ammoniac Posts: 213
    edited 2010-05-30 20:34
    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 GMike G Posts: 2,702
    edited 2010-05-30 20:47
    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)
    
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-05-30 20:58
    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 AmmoniacSal Ammoniac Posts: 213
    edited 2010-05-30 21:36
    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.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-05-30 21:59
    I've attached my dirt-simple tx object -- it may save you some time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
Sign In or Register to comment.