Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles


Not applicable


Question: What is the relationship between the data_out register, data_in register and data_direction register in relation to the GPIO posts of the EZ-OTG/EZ-Host chip?



The GPIO pins are fairly easy to use. The GPIO pins can be configured to have a pre-defined interface definition, which is described in the datasheet in the Interface Descriptions section. If a hardware interface such as HPI is not enabled and the GPIO pin is available then the free pin can be defined as either an input or an output. The direction is defined in the GPIO n Direction Register. You simply set up the direction register to specify each GPIO pin's definition (either an input or an output.) By default GPIO pins are defined as inputs meaning they would be in a high impedance state.


If a GPIO pin is set as an input, simply read the contents of the GPIO n Input register. All Inputs are sampled asynchronously with state changes occurring at a rate of up to two 48-MHZ clock cycles. GPIO pins are latched directly into registers with a single flip-flop. As an output simply write to the GPIO n Output Data Register. As an example to demonstrate both outputs and reading an input try the following using qtudump. 


If we want 3 GPIO pins to be outputs (let's say GPIO 2:0) then you would set the GPIO 0 direction register (0xC022 to 0x0007). Type in the following from a BASH shell prompt with your board connected : [cy]$ qtudump 0xC022 w 0x0007.

Now GPIO[2:0] are defined as outputs. Since the GPIO 0 Output Data Register by default is set to 0x0000, GPIO[2:0] should all go low. You can read these values by reading the GPIO 0 Input Data Register by doing a qtudump 0xC020 1 from the BASH shell prompt ([cy]$ qtudump 0xC020 1).

To make one output go high simply write to the GPIO0 Output Data Register using bash  shell command([cy]$qtudump 0xC01E w 0x0001) and the output should go high.Again a read should show the current value of the pin ([cy]$qtudump 0xC020 1).

Version history
Revision #:
1 of 1
Last update:
‎Oct 02, 2011 03:30 PM
Updated by: