Hi there.
I am having huge problems trying to get some simple GPIO set up on the Low Power node from the ZigBee Development Kit.
I have tried using the software drivers defined in the documentation, tried to alter GPIO control registers directly via the documentation in the reference manual and finally tried to manually alter states of the registers by using pointers to the base memory addresses of the relevant registers.
With each attempt the outcome was no voltage on any of the GPIO pins on the Low Power Node which I am trying to set as an output HIGH.
Any example code or a run through of the correct procedure to initialise GPIO if anyone else has used these pins would be greatly appreciated.
Scott
Solved! Go to Solution.
Hello Scott.
I recommend you to use the Demo applications as reference. For example: SMAC demo uses the GPIO driver to turn ON/OFF the LEDs in the evaluation boards.
#define Led1Off() (void)Gpio_SetPinData(LED1_PIN, LED_RESET) /* Set LED1 to OFF state */
You may init the GPIO by using the driver (option 1), or else writing direclty into the registers (option 2):
OPTION 1:
if (LEDNr & LED1){
Gpio_SetPinFunction(LED1_PIN, gGpioNormalMode_c); // LED1_PIN = gGpioPin23_c
Gpio_SetPinReadSource(LED1_PIN, gGpioPinReadReg_c);
Gpio_SetPinDir(LED1_PIN, gGpioDirOut_c);
Gpio_SetPinData(LED1_PIN, gGpioPinStateHigh_c);
OPTION 2:
static void PlatformInitGpio(void)
{
GPIO_REGS_P->DataLo = gDataLoValue_c; //MBAR_GPIO + 0x08
GPIO_REGS_P->DataHi = gDataHiValue_c; //MBAR_GPIO + 0x0C
GPIO_REGS_P->DirLo = gDirLoValue_c; //MBAR_GPIO + 0x00
GPIO_REGS_P->DirHi = gDirHiValue_c; //MBAR_GPIO + 0x04
GPIO_REGS_P->PuEnLo = gPuEnLoValue_c; //MBAR_GPIO + 0x10
GPIO_REGS_P->PuEnHi = gPuEnHiValue_c; //MBAR_GPIO + 0x14
GPIO_REGS_P->FuncSel0 = gFuncSel0Value_c; //MBAR_GPIO + 0x18
GPIO_REGS_P->FuncSel1 = gFuncSel1Value_c; //MBAR_GPIO + 0x1C
GPIO_REGS_P->FuncSel2 = gFuncSel2Value_c; //MBAR_GPIO + 0x20
GPIO_REGS_P->FuncSel3 = gFuncSel3Value_c; //MBAR_GPIO + 0x24
GPIO_REGS_P->InputDataSelLo = gInputDataSelLoValue_c; //MBAR_GPIO + 0x28
GPIO_REGS_P->InputDataSelHi = gInputDataSelHiValue_c; //MBAR_GPIO + 0x2C
GPIO_REGS_P->PuSelLo = gPuSelLoValue_c; //MBAR_GPIO + 0x30
GPIO_REGS_P->PuSelHi = gPuSelHiValue_c; //MBAR_GPIO + 0x34
GPIO_REGS_P->HystEnLo = gHystEnLoValue_c; //MBAR_GPIO + 0x38
GPIO_REGS_P->HystEnHi = gHystEnHiValue_c; //MBAR_GPIO + 0x3C
GPIO_REGS_P->PuKeepLo = gPuKeepLoValue_c; //MBAR_GPIO + 0x40
GPIO_REGS_P->PuKeepHi = gPuKeepHiValue_c; //MBAR_GPIO + 0x44
}
I hope this helps.
Hello Scott.
I recommend you to use the Demo applications as reference. For example: SMAC demo uses the GPIO driver to turn ON/OFF the LEDs in the evaluation boards.
#define Led1Off() (void)Gpio_SetPinData(LED1_PIN, LED_RESET) /* Set LED1 to OFF state */
You may init the GPIO by using the driver (option 1), or else writing direclty into the registers (option 2):
OPTION 1:
if (LEDNr & LED1){
Gpio_SetPinFunction(LED1_PIN, gGpioNormalMode_c); // LED1_PIN = gGpioPin23_c
Gpio_SetPinReadSource(LED1_PIN, gGpioPinReadReg_c);
Gpio_SetPinDir(LED1_PIN, gGpioDirOut_c);
Gpio_SetPinData(LED1_PIN, gGpioPinStateHigh_c);
OPTION 2:
static void PlatformInitGpio(void)
{
GPIO_REGS_P->DataLo = gDataLoValue_c; //MBAR_GPIO + 0x08
GPIO_REGS_P->DataHi = gDataHiValue_c; //MBAR_GPIO + 0x0C
GPIO_REGS_P->DirLo = gDirLoValue_c; //MBAR_GPIO + 0x00
GPIO_REGS_P->DirHi = gDirHiValue_c; //MBAR_GPIO + 0x04
GPIO_REGS_P->PuEnLo = gPuEnLoValue_c; //MBAR_GPIO + 0x10
GPIO_REGS_P->PuEnHi = gPuEnHiValue_c; //MBAR_GPIO + 0x14
GPIO_REGS_P->FuncSel0 = gFuncSel0Value_c; //MBAR_GPIO + 0x18
GPIO_REGS_P->FuncSel1 = gFuncSel1Value_c; //MBAR_GPIO + 0x1C
GPIO_REGS_P->FuncSel2 = gFuncSel2Value_c; //MBAR_GPIO + 0x20
GPIO_REGS_P->FuncSel3 = gFuncSel3Value_c; //MBAR_GPIO + 0x24
GPIO_REGS_P->InputDataSelLo = gInputDataSelLoValue_c; //MBAR_GPIO + 0x28
GPIO_REGS_P->InputDataSelHi = gInputDataSelHiValue_c; //MBAR_GPIO + 0x2C
GPIO_REGS_P->PuSelLo = gPuSelLoValue_c; //MBAR_GPIO + 0x30
GPIO_REGS_P->PuSelHi = gPuSelHiValue_c; //MBAR_GPIO + 0x34
GPIO_REGS_P->HystEnLo = gHystEnLoValue_c; //MBAR_GPIO + 0x38
GPIO_REGS_P->HystEnHi = gHystEnHiValue_c; //MBAR_GPIO + 0x3C
GPIO_REGS_P->PuKeepLo = gPuKeepLoValue_c; //MBAR_GPIO + 0x40
GPIO_REGS_P->PuKeepHi = gPuKeepHiValue_c; //MBAR_GPIO + 0x44
}
I hope this helps.