trouble passing variables
GrantmcF
Posts: 30
Still having trouble passing variable between cogs. In the attached code I'm trying to start a cog, have it run for 4 min then set a global variable as a flag for a later decision. The problems I'm having is that I can never get the flag set and the 240 sec timer doesn't always work. Any help is appreciated.
Comments
To:
Alternatively, you can just use:
Since all cogs within one object have access to all the global variables.
I suppose it doesn't hurt to keep setting the direction and output state of the pins but you could do these just once at the beginning of the method and then just loop your waitcnt only. Also the current method of waiting 240 seconds will be little off since it doesn't take into account the loop overhead. I think the waitcnt section of the Propeller manual has instructions on how to have more accurate wait times.
Call it like this using the address of a long that is in the global variable declarations:
I think passing the timing allows you to forget about the internals of this method once it works; your main code can adjust timing.
I want to point again onto
instead of
if you want to set more than one pin to value 1
you need to assign a value where every bit is set to 1
easiest way to do this is to use binary numbers through using the "%" in front of the digits
is the same as
best regards
Stefan