Shop OBEX P1 Docs P2 Docs Learn Events
Serial port Speed — Parallax Forums

Serial port Speed

KyeKye Posts: 2,200
edited 2013-03-21 16:41 in Propeller 1
I'm working on a serial port driver in C and I'm stuck on making a trade off.

I can either do:

A two port serial driver in one cog that does 115200 BPS. The two ports will have both RX and TX FIFOs which allows the LMM cog to not have to block on sending data.

A two port serial driver in one cog that does 230400 BPS. The two ports will have only RX FIFOs which means the LMM cog will have to block on sending data by bit banging itself.

Which is better? Should I go for the higher speed? Or, should I take the lower speed option which blocks the LMM cog less.

Thank you for suggestions.

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-03-20 11:29
    Personally, I'd prefer two ports and less speed.
    While extreme serial port speeds are possible on the Propeller, the 32K RAM limit is a rather small buffer. So the real question is what size are the actual data transfers going to be that require huge bursts of speed?

    Most of what I do with a Propeller is to send and recieve 20 or so bytes as a string. If some one really needs huge speed, they can dedicate a cog to another serial object that will do it in PASM.
  • KyeKye Posts: 2,200
    edited 2013-03-20 17:13
    Well, you get two ports either way.

    The issue is that for the lower speed version the LMM processor doesn't have to block on sending data while in the higher speed one it does.

    This becomes an issue when you run the really high speed port at a low speed. The non-blocking one seemingly becomes faster because the LMM core does not have to send the data at a slow baud rate itself.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-03-20 18:16
    Kye wrote: »
    I'm working on a serial port driver in C and I'm stuck on making a trade off.

    I can either do:

    A two port serial driver in one cog that does 115200 BPS. The two ports will have both RX and TX FIFOs which allows the LMM cog to not have to block on sending data.

    A two port serial driver in one cog that does 230400 BPS. The two ports will have only RX FIFOs which means the LMM cog will have to block on sending data by bit banging itself.

    Which is better? Should I go for the higher speed? Or, should I take the lower speed option which blocks the LMM cog less.

    Thank you for suggestions.

    If you run at much higher speeds like 3M baud or more you can forget about transmit buffering and simply bit-bang directly from the LMM cog and then have the other cog dedicated to receive which it can do really well. This is the approach I use in Tachyon. There is no reason to favour traditional baud rates of 115200 etc just because this is the highest speed some serial programs can run at as there are plenty of programs that don't have this limit such as Minicom.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-03-21 06:46
    115,200 baud is fine. Programs requiring > 115,200 are rare and will have other requirments too. 115,200 is a default that the prop chip uses for loading and this is the reason I use that as a fairly standard value.
  • David BDavid B Posts: 592
    edited 2013-03-21 10:47
    Why does there need to be a tradeoff; a decision on one or the other? Microcontrollers are used for such a wide variety of projects that wouldn't it make sense to offer a wide variety of serial port driver options?

    To go slightly off topic, after configuring a number of propeller projects that use serial devices, what would be most helpful to me would be a driver where receives and transmits could be configured independently.

    Most of the projects I've worked on have had several serial devices where some devices only received, like from a GPS sensor, and some only sent, like to an LCD display, but as often as not, they use different baud rates, forcing me to either customize an existing driver to allow different baud rates on send and receive, or to use multiple instances of a driver, where half of each driver goes to waste.

    Back on topic, I've ever only needed a FIFO on receive, but going further, I've had to increase the size of a receive FIFO before, so a configurable receive buffer size would be helpful to me. (Changing the buffer size of a library serial driver turned out to be pretty easy if the buffer size is kept as a power of 2.)
  • KyeKye Posts: 2,200
    edited 2013-03-21 12:37
    The driver is for an Arduino "like" OS for the propeller. I have to have something that is standard.

    The issue is blocking. If you transmit a huge message at 300 baud then everything else that the main core was doing is blocked on that message.

    I believe I'll go with the TX and RX FIFO options given this.

    Thank you,
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-03-21 15:33
    kye,agreed that is thebetteroption.

    david b, fullduplexserial_rr004 allows simple changes to the buffer sizes by changing a constant, butinpowers of 2. its in obex.
    also take a look at the 4port serial driver - cannot recall its precise name - its in obex.
  • David BDavid B Posts: 592
    edited 2013-03-21 16:41
    Oh, ok, thank you. I'll look at them.
Sign In or Register to comment.