Difference between revisions of "UDOO GPIO Pinout"

From eLinux.org
Jump to: navigation, search
(Creted GPIO UDOO Page)
 
m
Line 46: Line 46:
 
or
 
or
 
  echo 1 > /sys/class/gpio/gpioXX/value
 
  echo 1 > /sys/class/gpio/gpioXX/value
 +
 +
 +
==GPIOs Warnings==
 +
 +
When changing i.MX6 GPIOs directions, it is necessary to pay special attention. New direction must be compatible with SAM3x8E pinout configuration and/or with the load of the physical pin.
 +
 +
* A:GPIOs can be used to build a communication channel between the two processors. By setting one processor in INPUT mode, and the other in OUTPUT mode, a one-way channel will be created. Via software, it is possible to switch the direction on both processors, in order to create a half-duplex communication channel.
 +
* B:Two processors simultaneously can read data from external devices. They can also write data to external devices or the other processor, but only one at a time can be set in output mode.
 +
* C:The situations here illustrated must be avoided. In the first case, both processors set the shared pin in output mode. If they try to drive the shared line with different signal values, the resulting signal level will be unpredictable
 +
and it could result in damaging the processor driving the signal LOW. The same situation occurs when one external device tries to drive the shared line.
 +
 +
[[File:UDOO GPIO Warnings.jpg|thumb|900px|center|]]
 +
 +
'''WARNING!'''
 +
There isn’ t any automatic tool that can avoid dangerous situations. The programmer must develop Hardware and Software able to avoid the occurrence of dangerous situations.
 +
 +
==UDOO GPIO Pinout Diagram==
 +
[[File:Udoo_pinoutext.jpg|900px|center|]]

Revision as of 07:30, 24 July 2014

Introduction

In this chapter it will be described how UDOO manages the signals available on external pin header, and the way to control all the GPIOs. On UDOO, Freescale i.MX and Atmel SAM3X8E share most of the GPIOs available on external pin headers. Each pin of both processors can be set in INPUT or OUTPUT mode. In INPUT mode, each processor read the electrical level of the signal. In OUTPUT mode they can drive low or high the voltage level on each pin. So both processors can control all digital external pins. Usually, with Arduino Due, applications that manage external pins are developed to run on the SAM3x8E microcontroller. On UDOO it is possible to control external pins also using i.MX6 processor.


UDOO GPIO shared architecture

SAM3x8E GPI/Os management

SAM3x8E microcontroller can manage GPIOs using classic Arduino programming language. To manage a GPIO in Arduino Environment it is necessary to set its direction (input or output) by calling the pinMode(pin, mode) function.

pinMode(2, INPUT ); 
pinMode(2, OUTPUT );

If pin is set in input mode, its value can be read by using the function digitalRead(pin) providing pin number as parameter: e.g. int val = digitalRead(2); If pin is set in output mode, its value can be written by using the function digitalWrite(pin, value)providing the pin number and the value that must be written as parameters:

digitalWrite (2, HIGH); 
digitalWrite (2, LOW);

More information about Arduino programming Language can be found at Arduino Language Reference Page

i.MX6 GPI/O Management

i.MX6 can handle external pins in many different ways. In default configuration, they can be accessed from user level through the standard Kernel Linux interface. Some of them can be configured for specific functionalities provided by i.MX6 architecture, likespi, i2c, i2s, audiomux, pwms output, UARTs and so on. In next sections it will be described the way to use such functionalities. When a pin is set as a GPIO, it is possible to read its value, change its direction or change output value directly from console. All available GPIOs are managed by the kernel, and it is possible to access them simply by reading or writing value in specific files placed in a specific folder. In the /sys/class/gpio/ folder there are other sub-folders, one for each manageableGPIO. Each sub-folder contains files that indicate:

  • direction (in / out)
  • value (0 / 1)

To read a GPIO direction:

cat /sys/class/gpio/gpioXX/direction

In or Out output is now expected To change the pin direction:

echo out > /sys/class/gpio/gpioXX/direction

or

echo in > /sys/class/gpio/gpioXX/direction

It is possible to do the same for values read or written on the pin. To read a pin (the value read will be correct only if pin’ s direction is set as input):

cat /sys/class/gpio/gpioXX/value

0 or 1 output is expected To write a value on a pin:

echo 0 > /sys/class/gpio/gpioXX/value

or

echo 1 > /sys/class/gpio/gpioXX/value


GPIOs Warnings

When changing i.MX6 GPIOs directions, it is necessary to pay special attention. New direction must be compatible with SAM3x8E pinout configuration and/or with the load of the physical pin.

  • A:GPIOs can be used to build a communication channel between the two processors. By setting one processor in INPUT mode, and the other in OUTPUT mode, a one-way channel will be created. Via software, it is possible to switch the direction on both processors, in order to create a half-duplex communication channel.
  • B:Two processors simultaneously can read data from external devices. They can also write data to external devices or the other processor, but only one at a time can be set in output mode.
  • C:The situations here illustrated must be avoided. In the first case, both processors set the shared pin in output mode. If they try to drive the shared line with different signal values, the resulting signal level will be unpredictable

and it could result in damaging the processor driving the signal LOW. The same situation occurs when one external device tries to drive the shared line.

UDOO GPIO Warnings.jpg

WARNING! There isn’ t any automatic tool that can avoid dangerous situations. The programmer must develop Hardware and Software able to avoid the occurrence of dangerous situations.

UDOO GPIO Pinout Diagram

Udoo pinoutext.jpg