Using Port B “I/O Pins” to Synchronize Multi-cog Events
AwesomeCronk
Posts: 1,055
Just think of the memory you could save and the precision synchronization you might achieve!
One cog:
Other cog:
Basically one cog sets a nonexistent pin high and the other waits for it to get there and takes off!
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
-Phil
It has the COGATN and WAITATN instructions.
They wok great!
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
Enjoy!
Mike
But those tricks are interesting. Thanks.
@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!
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
"Spin and Pasm Debugger - Zero footprint"
http://obex.parallax.com/object/567
Really cool.
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.
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