Shop OBEX P1 Docs P2 Docs Learn Events
Using propeller standard SPI interface — Parallax Forums

Using propeller standard SPI interface

dr hydradr hydra Posts: 212
edited 2014-04-29 10:11 in Propeller 1
Using two propellers (A and B) and a SPI interface...how fast (or how many bytes per second) can you send data between them...for example...how long would in take to send 4,000 byte from Propeller (A) to Propeller (B)?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2014-04-29 08:32
    There really isn't a "standard" SPI interface, but it's one of a variety of clocked serial interfaces. Using PASM, this could be quite fast, a megabit per second or more is reasonable. There are ways to use the cog counters to do the clock generation that are somewhat faster.
  • dr hydradr hydra Posts: 212
    edited 2014-04-29 09:33
    what about in slave mode....how fast the propeller receive data....plus get that data from a cog to the hub memory...ex...receive 4000 bytes
  • jazzedjazzed Posts: 11,803
    edited 2014-04-29 10:03
    dr hydra wrote: »
    what about in slave mode....how fast the propeller receive data....plus get that data from a cog to the hub memory...ex...receive 4000 bytes
    Less than 0.1 seconds ;-)

    One could get a more accurate estimate by coding it though.
    pseudo-code assuming SPI with CS, CLK, RX, TX
    
    :doreceive
    if no chipselect, exit
    :getbyte
    wait for clock
    if clock timeout, exit
    save bit
    repeat :getbyte
    adjust rxqueue pointers
    save byte to hub
    repeat :doqueue
    :exit
    
    So, if the above algorithm results in about 24 instructions and the byte loop is about 4 instructions, then you might get a byte every 50 or so periods 50 instructions * 50ns = 2.5 us / byte or 400KB/s ... which is about 0.1 seconds for 4000 bytes ;-)

    Demonstrates why having a hardware helper is useful no ?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-04-29 10:11
    Why don't you just use async rather than SPI because there is no need to generate and synch to a clock. I have no problem transmitting and receiving at over 3M baud and certainly at 2M baud at 100% throughput (start bit, 8 data, 1 stop bit), so that's 200,000 bytes/sec or for 4,000 bytes that will take 20ms.

    If you can make it synchronous though then you could transmit and receive at up to 14.5Mbit/sec (BeauNet) so that's less than 3ms for 4,000 bytes.
Sign In or Register to comment.