I'm able to acces INPUT pins in a different cog without having DIRAed them?
gio_rome
Posts: 48
Hello,
as I've mentioned in another thread,
I've noticed that I (SEEM TO BE ABLE TO) access INPUT pins in a different cog without having DIRAed them.
e.g.
PUB MAIN
' Set input pin
dira[n1]~
dira[n2]~
....
cognew(input, @stack0)
PUB input
if INA[n1]==0 .... 'if I push the first button...
IT WORKS!
How's so? Am I missing something so that I have to look closer at the code?
G.
as I've mentioned in another thread,
I've noticed that I (SEEM TO BE ABLE TO) access INPUT pins in a different cog without having DIRAed them.
e.g.
PUB MAIN
' Set input pin
dira[n1]~
dira[n2]~
....
cognew(input, @stack0)
PUB input
if INA[n1]==0 .... 'if I push the first button...
IT WORKS!
How's so? Am I missing something so that I have to look closer at the code?
G.
Comments
In that other thread as well as trying to explain how this works my advice was:
It seems you have not done so.
Of course if you have but do not yet understand how to read the logic symbols in those diagrams then please do ask about that.
As stated previously the default state of the DIRA register in each COG at power up is zero, which means input. So we would expect to be able to read any pin from any COG if we do not change DIRA at all.
@Heater: Read the manual? Who has time for that?
Ha, yes perhaps I was being a bit hypocritical. I only open up the manuals when I get really stuck, stackoverflow or Google cannot answer the question or I get a helpful "RTFM" and a reference from someone.
Technically though I did not say read the manual, only look at the pictures
i thank you all, will try to be worthier next time :-)