Shop OBEX P1 Docs P2 Docs Learn Events
Continuous Data Read Limit — Parallax Forums

Continuous Data Read Limit

gis667en11gis667en11 Posts: 73
edited 2016-01-06 15:50 in Propeller 1
So I've been doing quite a bit of research into pushing a large amount of data continuously into the propeller. Hub access happens every 16 clock cycles, which means that a continuous write of longs to the hub from a single cog running at 80MHz happens at an average rate of 32 bits per 200 nanoseconds. This would mean that, if I wanted to read serial data and send it every 32 bits, because you might as well use WRLONG if all hub access ops take the same amount of time, you'd have to be able to get back before the next bit to catch it. So, hardware dictates that the absolute maximum possible baud rate for a single cog to pass serial data to hub is 5MHz / Mbaud. Correct? Of course with software limiting this potential significantly, I just want to make sure I'm getting the hang of the way the prop is put together.

Comments

  • (32 bits / 16 clocks) * (80,000,00 clocks / 1 second) = 160,000,000 bits/second. So, theoretical max cog -> HUB transmit of 160 Mbps. Of course, any useful software will limit this by just a wee little bit like you said.
  • gis667en11gis667en11 Posts: 73
    edited 2016-01-06 17:00
    Oh, doi. The hub transfer frequency is 5MHz max but moving 32 bits each time, so 32*5 = 160Mbaud. That's how fast a cog can write data to the hub. But, at 160Mbaud, the next bit on the serial input updates every 6.25 nanoseconds. So 160Mbaud isn't anywhere near the limit for reading a serial data stream and passing to hub.
  • I'm far from an assembly pro, so there's a good chance i'm wrong about this :)

    but I think hub instructions take 8 cycles. a jump takes 4. which means you don't even have enough time to increment the HUB address and change the value between writes if you want 160 Mbps. You can only do one or the other. Let alone do something vaguely useful like read from an 8-bit parallel port four times and combine the values. I suppose it is enough time to read for a 32-bit port and write to the same hub address constantly.
    start:  mov value, INA
            wrlong hubAddress, value
            jmp #start
    
  • I'm talking about a continuous serial data input being passed to hub. If hub access takes 200 nanoseconds you'll miss bits while the cog is writing to hub. Honestly, I'm very interested in writing a clocked 8 bit parallel bus. Those 8 bits can be shifted into a single long buffer and then sent to hub.
  • Ahh, yea that is hard. I've been wondering the same thing. Flow control might be important for you - so that the Propeller can inform the transmitter when it is ready for the next chunk of data.
  • I only need to do like 3 or 4 kBytes at a time. But, for a cog with 2kBytes of memory, the program needs to be able to run continuously with no overhead.

    For 3Mbaud clocked serial coming in, you've got 333 nanoseconds between clocks. Would be enough time to shift the bit in, increment the hub address, and every 32 bits write the long to hub?
  • gis667en11gis667en11 Posts: 73
    edited 2016-01-06 17:57
    I crunched some numbers and it's much better to do a faster baud with tiny breaks between cog buffers to write to hub. At 3Mbaud serial and writing to hub continuously, it would take 10.92ms to fill a 4kbyte hub buffer. At 7.8125Mbaud (don't ask) and pausing the data stream every 512bytes to write 128 longs to hub, each 512 read would take 524us and each hub write 25.6us for a total 4kbyte transfer time of 4.19ms. So, I'll be programming my master application to send data to the prop in bursts like that. But, I am still curious about the theoretical limit of continuous input to hub data streaming. Now the question is, how quickly can clocked serial be pushed into a cog buffer?
  • I'm thinking there is a trick I'm not thinking of but
    top waitpeq clockmask, clockmask   'wait for clock high
        tst ina, datamask wz               'test for data bit (need lots of hold time)
        if_nz or accum, #1                  'insert the bit     
        shl accum, #1                         'shift it
        djnz count32, #top                 'accumulate one full long
        mov cogbuffer, accum            'save it
        add #$-1, nextdest                'modify previous instruction
        mov count32, #32                 'next long
        jmp #top
    
    looks like nine instructions for every 32nd bit. Need to find a little external buffer somehow.
  • Beautiful code, tom. I love the add #$-1. Very clever. 9 instructions would mean 450 nanoseconds, suggesting a max continuous rate of 2.222 Mbaud
  • jmgjmg Posts: 15,173
    gis667en11 wrote: »
    ... suggesting a max continuous rate of 2.222 Mbaud
    Note that code assumes an external Clock ( & imposes some limits on it ) and does not cover handshake.

    If speed matters, rather than fighting serial, just use a FT240x, which has a code loop very similar to the one above.

    ie You Wait for RXF low, then RD low, get Byte, Rd Hi, and would unroll the 4 byte read/shifts - this has handshake inherent, and if you can read > 2M, that's ~16Mbd, so the USB is the limit, not the Prop.
    FT240 specs 8M Baud equiv.


  • The FT240x sounds amazing, jmg. Exactly what I wanted. I've migrated to considering using the raspberry pi zero, but would've loved to have left the usb port open for a flash drive. I wonder how debilitating a USB hub controller would be to the FT240's performance?
  • jmgjmg Posts: 15,173
    gis667en11 wrote: »
    The FT240x sounds amazing, jmg. Exactly what I wanted. I've migrated to considering using the raspberry pi zero, but would've loved to have left the usb port open for a flash drive. I wonder how debilitating a USB hub controller would be to the FT240's performance?

    Should be easy enough to test ?
    If you buffer enough into memory, they can alternate ?

  • "easy enough" is at least 30 dollars in parts to test a theory. I've got some pondering to do. Thanks again jmg
  • Cluso99Cluso99 Posts: 18,069
    Normally you can only execute 2 instructions between hub accesses. For a loop you need 3 instructions... The rd/we-long/word/byte + inc hub address, inc cog address, imp back to rd/wr. This will take 32 clocks or 2 hub cycles.

    Now there are a couple of tricks to this. If you perform the block copy in reverse, ie decrement rather than increment, you can catch every hub cycle. See my overlay loader in obex.

    Next, you can use 2 cogs to read the input, and flip between cogs while you do blocks. I use 4 cogs interleaved to read the input pins on every clock (12.5ns) on my data logger software.

    So once you get proficient with the prop, there are a lot of tricks we can use to really soup up the prop.

    And lastly you can overclock. I have been using 6.5MHz for years, but this requires special layout an decoupling!
Sign In or Register to comment.