Shop OBEX P1 Docs P2 Docs Learn Events
Using Port B “I/O Pins” to Synchronize Multi-cog Events — Parallax Forums

Using Port B “I/O Pins” to Synchronize Multi-cog Events

AwesomeCronkAwesomeCronk Posts: 1,055
edited 2019-03-30 11:31 in Propeller 1
Just think of the memory you could save and the precision synchronization you might achieve!
One cog:
Dirb[0] := %1
Outb[0] := %1

Other cog:
Waitpeq(forgot my syntax)

Basically one cog sets a nonexistent pin high and the other waits for it to get there and takes off!

Comments

  • I think it doesn't work that way - Port B's registers aren't hooked up to anything, IIRC
  • Aww. Man I thought I could start a revolution with this.😋
  • Cluso99Cluso99 Posts: 18,069
    Discussed many years ago :(
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2019-03-30 18:29
    The port B registers are just shadow registers exclusive to each cog, without any kind of interconnection between cogs. They're still usable as general-purpose registers, though.

    -Phil
  • BTW this feature is in the Propeller 2.
    It has the COGATN and WAITATN instructions.
    They wok great! :)
  • Unfortunately there are no HIDDEN I/O lines on P8X32A.
    If any, C flag is to be set (or cleared) for monitoring INB (INA, resp.) by WAITPxx.
  • msrobotsmsrobots Posts: 3,709
    edited 2019-03-31 05:25
    yisiguro wrote: »
    Unfortunately there are no HIDDEN I/O lines on P8X32A.
    If any, C flag is to be set (or cleared) for monitoring INB (INA, resp.) by WAITPxx.

    And who should change inb while waiting on it? No sadly as you stated inb/outb/dirb where never implemented.

    But in spin you can use them as repositories and for bit converting.


    Something like
       dirb[0..3] := a
       a := dirb[3..0]
    

    Enjoy!

    Mike
  • Cluso99Cluso99 Posts: 18,069
    There are other tricks with the shadow registers. You see, those special registers are also cog ram. I put a debug routine in there snd it can sinle step programs including spin. IIRC its in obex as well as a P1 thread.
  • My mother tongue is not English, so I might make you guys confused a little.
    But those tricks are interesting. Thanks.
  • AwesomeCronkAwesomeCronk Posts: 1,055
    edited 2019-03-31 11:08
    This is cool! @Cluso99, do you have a link to the obex site where that code is?

    @msrobots, this bit converting idea could be used to make string encrypters! Or to locate a single bit among a string or large number value!
  • @yisiguro,

    first of all welcome to the forum. Second, don't worry your English is quite fine as far I am concerned.

    It looks like you already went deep into the P1 but have just 14 posts, so be aware that this forum is addictive.

    At least I am addicted since a decade and do not regret it. I have learned a lot here and discovered whole new worlds of things I am interested in and am able to do with a Propeller and some help from my Friends Forum Members.

    I am programming the propeller (for fun) since a decade, have tons of useless (or not commercial usable) projects and still find out tips and tricks for the P1. It is a wonderful little beast.

    @AwesomeCronk,

    yes, it is not my idea, I stole it somewhere, and it is actually not a good practice to do so, even if Parallax never build the P1B with two ports, the open source FPGA versions of the P1 do/can support port B.

    And the P1 interpreter for the P2 does also support port B.

    But if intended to just run on a standard P1 then, yes Port B is open for grab and do bit manipulation with that nice [x..y] syntax.

    Enjoy!

    Mike
  • This is cool! @Cluso99, do you have a link to the obex site where that code is?

    "Spin and Pasm Debugger - Zero footprint"
    http://obex.parallax.com/object/567

    Really cool.
  • @msrobots
    Thanks for such an encouragement (isn't it, right?). Yes, I seem to be almost addicted. I'll take your advice to heart. Thanks again.
  • Now begs a landslide question. Can a compiler be hidden in the shadow register?
  • msrobotsmsrobots Posts: 3,709
    edited 2019-04-02 22:59
    Now begs a landslide question. Can a compiler be hidden in the shadow register?

    Oh no, it is a wonder that @Cluso99 could even fit a debugger in there, we are talking about a couple of longs usable for code execution at the end of the COG ram, normally used as control registers.

    Take ina for example.

    If you write to ina the value is written to the COG ram register.
    If you read from ina the value comes from the port, not from the COG ram register.
    That is while it is called a shadow register.

    But if you execute code from that location the COG does not fetch the code to execute from the port, but from the register in COG ram.

    Quit tricky,

    Mike
Sign In or Register to comment.