Basic GPIO usage from Linux on UDOO NEO board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Basic GPIO usage from Linux on UDOO NEO board

Basic GPIO usage from Linux on UDOO NEO board

  1. INTRODUCTION
  2. REQUIREMENTS
  3. HARDWARE CONNECTIONS
  4. IMPLEMENTATION AND TESTING

1. INTRODUCTION

This document explains how to generate and compile a custom Linux application on the UDOO NEO board  for using the GPIO headers to connect a 16x2 LCD.

2. REQUIREMENTS

First of all, the Linux image used is UDOObuntu 2 RC1 (Ubuntu 14.04), available for download from the following link:

     Downloads - UDOO

For creating a bootable SD card and other basic setup please refer to the following guidelines:

     Very First Start

Then, it is required to install the proper drivers to ensure connectivity, including USB communication with Linux terminal of the target board. Please refer to the link below:

     Usb Direct Connection

The LCD driver of this document was already implemented on a previous application, and could be found on the following document:
Customizing MQX applications on i.MX6SX.

3. HARDWARE CONNECTIONS

Now, the hardware connection considers a 4-bit interface to the LCD plus the Register Select (RS) and Enable (E) pins, so, six GPIO are used. For this example, digital input/output pins are used as shown on the following figure (purple rectangle):DOCS_internal_pinout.PNG

Where:

NEO GPIOGPIO148GPIO105GPIO149GPIO140GPIO141GPIO142
LCD pinERSDB7DB6DB5DB4

4. IMPLEMENTATION AND TESTING

After booting Linux, a text editor like nano should be used to generate the program. The three main configurations for GPIOS are the following (using the E pin as example):

  • Export the GPIO.
echo 148 > /sys/class/gpio/export
  • Configure the direction of the GPIO (as output).

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

  • Set the GPIO value to Low or High:

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

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

So, based on these configurations and the LCD driver already implemented on the document mentioned on Requirements section, the complete C application for Linux could be generated (find it attached).

The GCC compiler already included on the UDOObuntu image could be used to generate the executable application. The picture below shows the terminal of the UDOO NEO board including the text editor, compilation and execution commands of the application.

lcd neo.png

The used commands are the following:

$ nano lcd16x2_imx6sx.c

$ sudo gcc lcd16x2_imx6sx.c -o lcd

$ sudo ./lcd

Finally, the following image shows the LCD with the application working on the UDOO NEO board, connecting the LCD using a proto shield:

lcd.jpg

NOTE: Ensure that M4 core is not running or using the same pins, in order to avoid unexpected behavior on GPIOs.

Attachments
No ratings
Version history
Last update:
‎09-10-2020 02:43 AM
Updated by: