9 Replies Latest reply on Jan 27, 2015 1:30 PM by CMata_Intel

    Please, help with GPIO setup (both boards)

    NikkiC

      I've read Edison GPIO Multiplexing Guide. The great document, but incomplete. Probably it is enough for people who had the experience with arduino/RPI before. Unfortunately it is not my case. I need just few hints to see the whole picture. Please, help me to fill the gaps.

       

      1. Arduino Board: how to setup IO.7 pin for output with pull resistors disabled? The special problem for me is what value should I store into /sys/class/gpio/gpio48/direction? "in"? or "out"? I cannot find anywhere in docs in what cases i can store "out" there. And the guide is mostly focused on configuring pins for input.

       

      2. Mini board: how to setup i2c-6 pins with typical resistors config? Cannot find any info or examples on that either.

       

      3. Mini board: how to setup spi5 pins?

       

      4. Mini board: how to setup UART1 pins?

       

      Thank you.

        • 1. Re: Please, help with GPIO setup (both boards)
          CMata_Intel

          Hi NikkiC

           

          About 1. have you tried changing also the pins 255 and 223 as the table 3 states?

          About 3 and 4, a good way to do this is using MRAA, I'm not sure if you have already look at it :

          mraa: Main Page

          intel-iot-devkit/mraa · GitHub

          About 2; Do you need a resistors recommendation to use I2C as pullup resistors? or do you only want to configure the pins to use I2C?

           

          Regards;

          CMata

          • 2. Re: Please, help with GPIO setup (both boards)
            KurtE

            Others can answer more/better than I can but will give a few stabs.  Would help to know more like how you are planning to program it.

             

            For example with question #1:

            If using Arduino IDE, you simply need to do a call: pinMode(7, OUTPUT);

            And it should do all of the right stuff to set it up for output.  If you are using MRAA, you can probably do all of this with a couple of calls:

             mraa_gpio_context gpioRST = NULL;
             gpioRST = mraa_gpio_init(7);
            
              if (gpioRST) {
                mraa_gpio_dir(gpioRST, MRAA_GPIO_OUT);
                mraa_gpio_write(gpioRST, 0);
              }
            

             

            Shows an example sort of extracted from some code I had up.. But quick look at the variant.cpp from Arduino IDE, doing the pinMode(7, OUTPUT) will do:

            Set pinMux (214) Low (sets direction=out, value=0)  Note using File system call like: echo low > /sys/class/gpio/gpio214/direction is a short cut for setting the direction=out, value=0)

            Set Direction (255) HIGH (direction=out, value = 1)

            Set Pull up/dn to (223) NONE (direction=in)

            Set MUX (48) Mode0 (mode0 > /sys/kernel/debug/gpio_debug/gpio48/current_pinmux)  Assuming my memory correct here.

            Sets pin to output: (48) (direction=out)

            Set pinMux(214) High (direction=out, value=1)

             

            Note in the above I am assuming that pin has been exported.  if not you may need to do the echo of the pin number to export...

             

            2. Typical Resistor config?  I had questions here earlier.  Normally I would say assume no PU and use external PU resistor.  Alternatively you can try to enable PU

            Again most of the setup stuff is done automagically by Arduino or MRAA...

            I2C6 pin Example: J17-7 SCL - Is MRAA pin 6 and Edison pin GP27.  I believe the steps are:

            Set pin to output (out > /sys/class/gpio/gpio27)

            set pin to I2c Mode (mode1 > /sys/kernel/debug/gpio_debug/current_pinmux)

             

            Maybe set Pull up on this pin (pullup > /sys/kernel/debug/gpio_debug/current_pullmode)

            or turn it off?  (nopull > ... /pullmode)

            If you turn it on, you may want to set the strength of the PU values are: 2K, 20K, 50K 910ohms

            example (echo 20K > /sys/kernel/debug/gpio_debug/current_pullstrength)

             

            3) Again part of Arduino IDE and MRAA

            SCL, MOSI and optionally CS pin) are very much like the above for I2C SCL, except probably don't need to worry about PU.  Would probably do the nopull as above.  As for MISO, similar except would probably need to set the pin as Input instead of output.  Again pretty sure it is mode1 to current_pinmux

             

            4) UART - again like 2) and 3) Personally I have only dealt with RX and TX.  but assume optional RTS/CTS are the same...

             

            When it comes to mini board, I personally keep my own hard copy cheat sheet on my desk to look up pin information.  It is similar to others out there and I keep it up in one of my github projects:

            Intel-Edison-and-Galileo/MRAA Edison Mini-Breakout board Pin usage.xlsx at master · KurtE/Intel-Edison-and-Galileo · Git…

             

            Hope that helps some

            • 3. Re: Please, help with GPIO setup (both boards)
              NikkiC

              CMata_Intel,

               

              I did not look at MRAA before and it seems it cover most of my needs. Thank you for the reference and links.

              Except one case when I want to write linux driver for i2c device. So I still need to know a way how to configure pins for I2C on Mini board.

              • 4. Re: Please, help with GPIO setup (both boards)
                NikkiC

                KurtE,

                 

                I configured I2C GPIO 27-28, but i2cdetect and i2cdump do not work for me on mini board. Always return empty values. Not sure if I should write 'in' or 'out' into gpio28/current_direction. But both cases do not work anyway.


                And I get a lot of errors in dmesg:

                 

                [ 2832.642798] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration


                I'm not very sure if my GPIO configuration is wrong, or my 1.8-3.3 level converter is not compatible with i2c device. When I tried the same device on Edison Arduino board without level converter and using the GPIO configuration from the Emutexlabs' guide everything worked fine.

                 

                My GPIO configuration on mini board is

                 

                /sys/class/gpio/gpio27/active_low: 0

                /sys/class/gpio/gpio27/direction: out

                /sys/class/gpio/gpio27/edge: none

                /sys/class/gpio/gpio27/value: 1

                /sys/kernel/debug/gpio_debug/gpio27/conf_reg: 0x00000511

                /sys/kernel/debug/gpio_debug/gpio27/current_debounce: disable

                /sys/kernel/debug/gpio_debug/gpio27/current_direction: out

                /sys/kernel/debug/gpio_debug/gpio27/current_irqtype: irq_none

                /sys/kernel/debug/gpio_debug/gpio27/current_opendrain: disable

                /sys/kernel/debug/gpio_debug/gpio27/current_override_indir: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_override_inval: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_override_outdir: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_override_outval: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_pinmux: mode1

                /sys/kernel/debug/gpio_debug/gpio27/current_pullmode: pullup

                /sys/kernel/debug/gpio_debug/gpio27/current_pullstrength: 20k

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_indir: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_inval: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_opendrain: disable

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_outdir: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_outval: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_pullmode: keep

                /sys/kernel/debug/gpio_debug/gpio27/current_standby_trigger: no-override

                /sys/kernel/debug/gpio_debug/gpio27/current_value: high

                 

                /sys/class/gpio/gpio28/active_low: 0

                /sys/class/gpio/gpio28/direction: in

                /sys/class/gpio/gpio28/edge: none

                /sys/class/gpio/gpio28/value: 1

                /sys/kernel/debug/gpio_debug/gpio28/conf_reg: 0x00000591

                /sys/kernel/debug/gpio_debug/gpio28/current_debounce: disable

                /sys/kernel/debug/gpio_debug/gpio28/current_direction: in

                /sys/kernel/debug/gpio_debug/gpio28/current_irqtype: irq_none

                /sys/kernel/debug/gpio_debug/gpio28/current_opendrain: disable

                /sys/kernel/debug/gpio_debug/gpio28/current_override_indir: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_override_inval: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_override_outdir: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_override_outval: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_pinmux: mode1

                /sys/kernel/debug/gpio_debug/gpio28/current_pullmode: pullup

                /sys/kernel/debug/gpio_debug/gpio28/current_pullstrength: 20k

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_indir: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_inval: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_opendrain: disable

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_outdir: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_outval: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_pullmode: keep

                /sys/kernel/debug/gpio_debug/gpio28/current_standby_trigger: no-override

                /sys/kernel/debug/gpio_debug/gpio28/current_value: high

                • 5. Re: Please, help with GPIO setup (both boards)
                  KurtE

                  Sorry, I have not done very much with I2C yet.  Was simply trying out an earlier compass device and I was using MRAA and trying to get Arduino IDE to work with it.  I was getting strange results on the IO pin so not sure.   More details of my experiments are in the thread: https://communities.intel.com/thread/57339

                  • 6. Re: Please, help with GPIO setup (both boards)
                    NikkiC

                    Thank you, your thread is very interesting. I saw it before, but did not read carefully at that time.

                     

                    By now I would like to make work just i2cdetect/i2cdump programs. As soon as it will work, I probably could handle the rest.

                     

                    Today I tried to initialize i2c pins with python code and mraa.I2c(USED_I2C) in it, but i2c-tools does not work after that.

                     

                    In next few days I going to try the workaround from Using i2cdetect on the Intel Edison…and getting I2C6 to work on the mini breakout board | richards-tech notes Also I'm going to take an oscilloscope and look at the lowest levels it nothing else will help. I ordered sparkfun's converters, still waiting for it. By now use these ones: Logic Level Converter 8 Channels Bus Transceiver Module Bidirectional Shifter | eBay . Not sure if it i2c compatible.

                    • 7. Re: Please, help with GPIO setup (both boards)
                      KurtE

                      that looks like the shifter I purchased from Amazon.com that shipped from China.  I had problems with it on spi, switched to adafruit one and had tft display working.  But I was using different one for I2C as adafruit documents suggested a different one was needed as the stronger pus can confuse the other one.  I believe the one I used from adafruit has PU resistors on both sides of level converter.

                      • 8. Re: Please, help with GPIO setup (both boards)
                        mhahn

                        NikkiC wrote:

                         

                        CMata_Intel,

                         

                        I did not look at MRAA before and it seems it cover most of my needs. Thank you for the reference and links.

                        Except one case when I want to write linux driver for i2c device. So I still need to know a way how to configure pins for I2C on Mini board.

                        you might check the mraa code?

                        • 9. Re: Please, help with GPIO setup (both boards)
                          CMata_Intel

                          Hi NikkiC

                           

                          What happened with the workaround that you tried?? Any updates in this?

                           

                          Best Regards;

                          CMata