SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
Each bit in the global I/O register is defined as a single bit bit-field inside the UCD3138_misc_analog.h header file.
The following examples demonstrate interaction with these bits. The examples also intend to clarify and compare the utilization of local peripheral controls versus the use of centralized “Global I/O” controls.
Example 1: Setting a DPWM3B pin as a general purpose output (GPO), and set the output high. The following examples demonstrate two alternatives.
Example 1.1: configuration through DPWM registers:
Dpwm3Regs.DPWMCTRL1.bit.GPIO_A_ENA = 1; // Configure DPWM3A as a GPIO
Dpwm3Regs.DPWMCTRL1.bit.PWM_A_OE = 0; // 0 means output, 1 means input
Dpwm3Regs.DPWMCTRL1.bit.GPIO_A_VAL = 1; // Set output to high
Example 1.2: configuration through Global I/O registers:
MiscAnalogRegs.GLBIOEN.bit.DPWM3A_IO_EN = 1; // Set DPWM3A as GPIO
MiscAnalogRegs.GLBIOOE.bit.DPWM3A_IO_OE = 1; // 1 = output, 0 = input
MiscAnalogRegs.GLBIOVAL.bit.DPWM3A_IO_VALUE = 1;// Set output to high
Example 2: Setting a pin as a general purpose input (GPO). The following examples demonstrate two alternatives.
Example 2.1: configuration through GIO (fault) registers:
GioRegs.FAULTDIR.bit.FLT2_DIR = 0;// 1 means output, 0 means input
Example 2.2: configuration through Global I/O registers:
MiscAnalogRegs.GLBIOEN.bit.FAULT2_IO_EN = 1; //Configure FAULT2 as GPIO
MiscAnalogRegs.GLBIOOE.bit.FAULT2_IO_OE = 0; // 1 = output, 0 = input