COG "ownership" of I/O PINS
DavidM
Posts: 630
HI everyone,
I haven't posted for ages, but I can tell you I have been extremly busy for the whole year! ( and I do read this forum everyday to keep in touch)
I have a issue with accessing I/O pins and COGS that use them.
I have a main loop ( cog 0 )and that main loop needs to set ( Initialize) the direction & the state of a I/O pin, in this case an OUTPUT & LOW
During programm execution, this same pin need to be change to HIGH but within a NEW COG, then when the cog is finished , the main loop ( therefore the first COG ) will control this pin. ( I am pretty sure that never a cog wants to act upon the same pin at at the same rime, i.e they take turns)
For some reason my second cog seems to not make any differnece to the state of the PIN.
I thought I have solved this issue years ago! as I have done a similar thing before.
What I normally do I in my NEW COG routine is to "re-initialize" the direction using..
DIRA[MyPin] := Output ( so that this cog "owns" the pins direction) So I believe.
I then set the state ( hi or low ) as needed. but this does not apper to be working
Can any one shed some light on where I am going wrong?
Thanks
Dave M
I haven't posted for ages, but I can tell you I have been extremly busy for the whole year! ( and I do read this forum everyday to keep in touch)
I have a issue with accessing I/O pins and COGS that use them.
I have a main loop ( cog 0 )and that main loop needs to set ( Initialize) the direction & the state of a I/O pin, in this case an OUTPUT & LOW
During programm execution, this same pin need to be change to HIGH but within a NEW COG, then when the cog is finished , the main loop ( therefore the first COG ) will control this pin. ( I am pretty sure that never a cog wants to act upon the same pin at at the same rime, i.e they take turns)
For some reason my second cog seems to not make any differnece to the state of the PIN.
I thought I have solved this issue years ago! as I have done a similar thing before.
What I normally do I in my NEW COG routine is to "re-initialize" the direction using..
DIRA[MyPin] := Output ( so that this cog "owns" the pins direction) So I believe.
I then set the state ( hi or low ) as needed. but this does not apper to be working
Can any one shed some light on where I am going wrong?
Thanks
Dave M
Comments
Based on your description you shouldn't be having problems. And FWIW, here's a little demo
Thanks for replying
So If COG 0 starts with..
DIRA[MyPin1] := Output and OUTA[MyPin1] := High,
Then COG 1 does..
DIRA[MyPin1] := Output and OUTA[MyPin1] := High,
Will the result of MyPin1 be HIGH?, AND Do I need to Declare "DIRA[MyPin1] := Output" again in the second cog??
OR
If COG 0 says..
DIRA[MyPin1] := Output and OUTA[MyPin1] := High,
Then COG 1 says..
DIRA[MyPin1] := Output and OUTA[MyPin1] := Low,
will the result of MyPin1 be Low ?? or do I have to get COG0 to make MyPin1 := LOW, before letting COG1 take control??
Thanks
Dave M
Yes, each COG has to set the output-pins in DIRA because each COG has it's own DIRA-register.
Thanks for the replies well explained!,
I can see know where i was going wrong, I have discovered that I don't actually need to control this particular pin from the second cog, I can set it just before the cog starts, and reset it back when the cog finishes.
But sometime this type of control of a pin need to be done,
Thanks
Dave M
Page 8 of the Data Sheet may make things clearer:
http://www.parallaxsemiconductor.com/sites/default/files/parallax/Propeller-P8X32A-Datasheet-v1.4.0_1.pdf