We have a project running that began as one of the UPP EvmA/B examples
We are trying to add support for GPIO . We want to a few pins from banks 0, 7, and 8
How do we configure the pins to use them for GPIO?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
We have a project running that began as one of the UPP EvmA/B examples
We are trying to add support for GPIO . We want to a few pins from banks 0, 7, and 8
How do we configure the pins to use them for GPIO?
Hi Mitch,
You can refer the sample application provided by the BIOS PSP in configuring the pins as GPIO.
Known that there are a few caveats in the sample code, I have corrected and metioned them in our earlier conversation(http://e2e.ti.com/support/embedded/f/355/p/122176/436096.aspx#436096).
Keeping these in mind, you can also refer the BIOSPSP_gpio.chm file placed in: pspdrivers_01_30_01\packages\ti\pspiom\gpio\docs for more details regarding API functionalities and usage.
For configuring pins to use them as GPIO, first thing is to set the PINMUX appropriately. Next, can proceed further using the GPIO driver.
For Example: if you are using 0th pin of bank 0, you can use API -
/* To Configure GPIO(GPIO0_0_PIN) as an input */
Gpio_PinCmdArg pinCmdArg;
pinCmdArg.pin = 1u;
pinCmdArg.value = Gpio_Direction_Input;
Gpio_setPinDir(gpio0, &pinCmdArg);
Gpio_setPinDir(...) to set the direction for the pin by specifying the pin number, and the value(Input/output) in Gpio_PinCmdArg
Gpio_setPinVal(...) to set the pin value. etc..
Hope this helps. Incase you need any more information, please let us know..
Thanks & regards
Raghavendra
Rghavendra,
That does not answer the question (once again, please read the question).
The problem is that the pins are shared with other peripherals.
As a guess, I think we need to do something with the pin mux.
MCN
Here is more detail
1) We can read pins, and so far it seems we can read any pin.
What that means is that for pins configured as inputs, we call Gpio_getPinVal(), we see a 1 or a 0, depending on whether we connect the pin to 3.3V or to ground.
2) We have not been able to set the output for any pin,.
For pins that are configured as outputs, we look at the outputs with an oscilloscope or volt meter, and the output level does not change when we call Gpio_setPinVal().
That the problem is in the pin-mux is only a guess.
I solved it. Here is the answer:
Step 1) Generate a Header file that has the PIN MUX settings
Step 2) Write a function to setup the mux, and call it from main(). Here is an example mux configuration that actually works.
#include <std.h>
#include <gio.h>
#include <assert.h>
#include "ti/pspiom/cslr/soc_C6748.h"
#include "ti/pspiom/cslr/cslr_syscfg0_C6748.h"
#include "PINMUX.h"
#define KICK0_REGISTER (*(volatile Uint32 *)0x01C14038u)
#define KICK1_REGISTER (*(volatile Uint32 *)0x01C1403Cu)
#define KICK0_ENABLE_KEY 0x83E70B13u
#define KICK1_ENABLE_KEY 0x95a4f1e0u
Int32 configPinMux(Void)
{
Int32 status = 0;
CSL_SyscfgRegsOvly sysCfgRegs = (CSL_SyscfgRegsOvly)CSL_SYSCFG_0_REGS;
/* Enable write access to PINMUX and CFG registers in KICK0R and KICK1R */
KICK0_REGISTER = KICK0_ENABLE_KEY;
KICK1_REGISTER = KICK1_ENABLE_KEY;
sysCfgRegs->PINMUX0 = PINMUX0_VALUE ;
sysCfgRegs->PINMUX1 = PINMUX1_VALUE ;
sysCfgRegs->PINMUX2 = PINMUX2_VALUE ;
sysCfgRegs->PINMUX3 = PINMUX3_VALUE ;
sysCfgRegs->PINMUX4 = PINMUX4_VALUE ;
sysCfgRegs->PINMUX5 = PINMUX5_VALUE ;
sysCfgRegs->PINMUX6 = PINMUX6_VALUE ;
sysCfgRegs->PINMUX7 = PINMUX7_VALUE ;
sysCfgRegs->PINMUX8 = PINMUX8_VALUE ;
sysCfgRegs->PINMUX9 = PINMUX9_VALUE ;
sysCfgRegs->PINMUX10 = PINMUX10_VALUE ;
sysCfgRegs->PINMUX11 = PINMUX11_VALUE ;
sysCfgRegs->PINMUX12 = PINMUX12_VALUE ;
sysCfgRegs->PINMUX13 = PINMUX13_VALUE ;
sysCfgRegs->PINMUX14 = PINMUX14_VALUE ;
sysCfgRegs->PINMUX15 = PINMUX15_VALUE ;
sysCfgRegs->PINMUX16 = PINMUX16_VALUE ;
sysCfgRegs->PINMUX17 = PINMUX17_VALUE ;
sysCfgRegs->PINMUX18 = PINMUX18_VALUE ;
return (status);
}