Shop OBEX P1 Docs P2 Docs Learn Events
I'm able to acces INPUT pins in a different cog without having DIRAed them? — Parallax Forums

I'm able to acces INPUT pins in a different cog without having DIRAed them?

gio_romegio_rome Posts: 48
edited 2014-02-11 07:15 in Propeller 1
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.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2014-02-11 01:32
    gio_rome,

    In that other thread as well as trying to explain how this works my advice was:
    Do have a look at the Propeller architecture diagrams in the manual to see why this is so. Pages 20 and 21. There is also a written description in there somewhere.

    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.
  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-02-11 02:55
    @gio_rome: Asking the same question in two different threads will not yield different results.

    @Heater: Read the manual? Who has time for that? ;)
  • Heater.Heater. Posts: 21,230
    edited 2014-02-11 03:05
    JonnyMac,

    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 :)
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-02-11 05:03
    This is the beauty of the prop... All cogs canalways read the pins at any time. More than one can drive a pin at the same time and the values will be ORed together without any hardware contention (both cogs set the DIR pin =1, and OUTA pin =x and =y)
  • gio_romegio_rome Posts: 48
    edited 2014-02-11 06:44
    sorry everybody. it was so simple and i just didn't see it.
    i thank you all, will try to be worthier next time :-)
  • Heater.Heater. Posts: 21,230
    edited 2014-02-11 07:15
    No worries. We all get that some time.
Sign In or Register to comment.