6 Replies Latest reply on Nov 12, 2013 8:39 AM by Dan.McCulley

    PORTB and DDRB on Quark?

    Intel_SteveH

      I'm experimenting with Galileo. As an experiment, I wanted to try using PORTB on digital pins 8-12. Intel indicates that Galileo is pin compatible with Arduino Uno, and PORTB works on the Uno. However, I was unable to get it to work on Galileo.

       

      PORTB and DDRB are returned as compile errors as "not defined in this scope." In all the examples I've seen online, you don't have to declare these variables, but you DO have to have the AVR package installed (I'm running Ubuntu 13.10). I don't have that package because that's specific to the Arduino hardware, not the x86 Quark.

       

      I tried to declare them as INT, and the code compiled but didn't do anything. I sent values using a shift command in a loop, and using Serial.println, I was able to see the correct values (shifting from 1->2->4->8 and back again). However, my LEDs didn't light. I had another version of the same code that lit the LEDs just fine, but it manually cycled through them individually, vs. setting them all simultaneously via the PORTB command.

       

      Am I missing something here? Is PORTB (or PORTD, et al.) implemented on Galileo/Quark? Is this one case where Galileo/Quark will NOT be pin compatible with Uno?

        • 1. Re: PORTB and DDRB on Quark?
          arduino_4_life

          Intel_SteveH,

          it's not a pin compatibility issue. Galileo is pin compatible with the UNO. The reason you can't use PORTD is because PORTD is the name of an actual register on the Atmel MCUs- since Quark is x86 architecture then you can't use the same direct hardware calls that you can on an Arduino.

          http://arduino.cc/en/Reference/PortManipulation

          • 2. Re: PORTB and DDRB on Quark?
            Intel_SteveH

            Right... I read that article on Port Manipulation. It's all about PORTB /C /D on Arduino, yes. My question is, "are they the same pins on x86?" How do I use DDR registers on Quark?

            • 3. Re: PORTB and DDRB on Quark?
              arduino_4_life

              I'm still not sure I understand your question "are they the same pins on x86".

              the Atmel chip on an Arduino is an 8bit microcontroller. No OS. You can directly read/write the port manipulation registers if you want to.

              Quark is a 32 bit System on a Chip. Things are a bit more complicated. Linux is running and the best way to easily access GPIOs is through Linux- either with an Arduino sketch which runs as a userspace program or through the sysfs interface (/sys/class/gpio).

              If you need to set a block of pins simultaneously, I don't think you have that ability through an Arduino sketch, but it may be possible if you use Linux directly. Google around for sysfs (standard userspace GPIO control), you'll probably find something.

              • 4. Re: PORTB and DDRB on Quark?
                Intel_SteveH

                That's pretty much the answer. Basically, does Intel emulate the PORTX functionality on Quark, so I can take PORTB code examples from the web, written for popular Arduino boards, and run it on Galileo. It sounds like the answer is "no."

                 

                I DO understand that it's vastly different hardware, I just wanted to try out direct hardware access, and how far "pin compatible" went. I looked through various Quark datasheets and other documents from this site and saw the GPIO stuff, but didn't see any easy way to access it through the IDE or a sketch.

                • 5. Re: PORTB and DDRB on Quark?
                  arduino_4_life

                  from a sketch- digitalWrite is really the only option for Galileo (and it's no faster or slower than writing directly to sysfs within linux).

                  However, for faster IO, you CAN configure IO2 and IO3 to be faster (straight from t he SoC, rather than through the Cypress IO expander) by using pinMode() function as follows;

                   

                  pinMode(2, INPUT_FAST);

                  pinMode(3, INPUT_FAST);

                  • 6. Re: PORTB and DDRB on Quark?
                    Dan.McCulley

                    And the next questions is, when will Intel get around to implementing a code solution for the Arduino class to emulate this functionality?

                     

                    Arduino's appeal are the large number of code samples on the web.  So far, I've run into issues with Temp Sensors, Depth Sensors, and screens with my Galileo.  Not exactly Arduino equivalent.  In fact, pretty much completely useless for everything I've tested so far.

                     

                    Who is working on fixing these missing core capabilities?  What is the timeline?

                     

                    And to simplify, as Intel_SteveH wrote: "When will Intel emulate the PORTX functionality on Quark, so I can take PORTB code examples from the web, written for popular Arduino boards, and run it on Galileo. "