How to configure the input and output of a GPIO in the TMS320C6000 series DSP?
[Copy link]
1) Enable the general purpose input and output port peripheral (GPIO).
// Enable the GPIO module (the corresponding peripheral module can also be enabled in BootLoader)
PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
2) Configure the corresponding GPIO port as a normal input and output port (select the multiplexing function in I/O multiplexing).
savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) &
~(SYSCFG_PINMUX1_PINMUX1_31_28)); //Read the value of the corresponding register
HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) =
(PINMUX1_GPIO0_0_ENABLE | savePinmux); //Set the value of the corresponding register
HWREG: Macro definition of the value of the peripheral register.
3) Configure the corresponding GPIO port as input or output.
GPIODirModeSet(SOC_GPIO_0_REGS, 1, GPIO_DIR_OUTPUT); GPIO_DIR_INPUT
4) Configure the corresponding GPIO port to input or output high or low levels.
GPIOPinWrite(SOC_GPIO_0_REGS, 1, GPIO_PIN_LOW); //Low level GPIO0[0]
GPIOPinWrite(SOC_GPIO_0_REGS, 1, GPIO_PIN_HIGH); //High level GPIO0[0]
|