Shop OBEX P1 Docs P2 Docs Learn Events
Faster Data Output: Parameter passing between cogs — Parallax Forums

Faster Data Output: Parameter passing between cogs

JamesxJamesx Posts: 132
edited 2007-01-30 19:41 in Propeller 1
I am using the FullDuplex object for outputting data at 230400 baud. Data starts in an assembly-cog (from an A/D chip). Currently this data is managed and processed by some spin code in both PC_Debug and FullDuplex, on its way to the assembly cog associated with FullDuplex. This all works great, but the spin part is slowing me down and some of the data is getting dropped.

My question is: how can parameters be passed between two cogs, each running assembly code, without using spin? Is there some trick with @@ or something like that?

Jim C

Comments

  • rokickirokicki Posts: 1,000
    edited 2007-01-29 21:17
    This is easy; use exactly the same techniques used for Spin->Assembly communication. Just use a
    main memory buffer, allocated at the spin level, and pass the address of this buffer to both
    assembly language cogs that plan to communicate.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-29 21:23
    Data can be passed from one cog to another the same way it would be passed if one cog were running Spin. You need some kind of common buffer in hub memory and a management scheme that prevents both cogs from problems with simultaneous access to the same variables. If you have one cog generating data and a second cog consuming it, you can use a simple ring buffer and not have to use semaphores (locks). Rather than rewriting the FullDuplexSerial driver, you could add a simple method to the FullDuplexSerial object that just returns the address of the block of data used by the assembly part of the FullDuplexSerial driver. This address would be passed to your new assembly routine when it's started up and you'd have an assembly version of the TX routine in your assembly routine. Note that you couldn't have two cogs trying to transmit at the same time. If that's what you need, you'd have to use the LOCKxxx instructions so only one transmit routine could change the variables at a time.
  • JamesxJamesx Posts: 132
    edited 2007-01-30 19:41
    Thanks Mike and Rokicki

    I've give it a go and see what shakes out.

    Jim C
Sign In or Register to comment.