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.

GPIO_02 NOT WORKING as GPIO output

GPIO02's output is always 0. 

The following code uses either GPIO_IF or gpio.h to create PWM wave, however, GPIO_02 only outputs 0. While when the same code applies GPIO_08, the PWM works perfectly.

TI technical support team: Can you verify on your side?

int main(void) {


BoardInit();

UDMAInit();

InitTerm();

MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);

MAP_PinTypeGPIO(PIN_57, PIN_MODE_0, false); // GPIO_2 mode
MAP_GPIODirModeSet(GPIOA0_BASE, 0x04, GPIO_DIR_MODE_OUT); // GPIO_2 as output

unsigned int gpio2_port;

unsigned char gpio2_pin;

//GPIO_IF_GetPortNPin(2, &gpio2_port, &gpio2_pin);

while(1) {

// set to 0 method A:

//GPIO_IF_Set(2, gpio2_port, gpio2_pin, 0); // does not work

// set to 0 method B:

MAP_GPIOPinWrite(GPIOA0_BASE,GPIO_PIN_2,0); // does not work

MAP_UtilsDelay(8000000);

// set to 1 method A:

//GPIO_IF_Set(2, gpio2_port, gpio2_pin, 1); // does not work

// set to 1 method B:

MAP_GPIOPinWrite(GPIOA0_BASE,GPIO_PIN_2,GPIO_PIN_2); // does not work

MAP_UtilsDelay(8000000);

}

  • New test results:

    GPIO08,GPIO09,GPIO22 works well for alternating 1 and 0 outputs.

    BUT,
    GPIO02,GPIO07,GPIO28 don't. They all behave the same: all outputs 0 constantly.

    Please advice.
  • I modified the 'blinky' application of the SDK to toggle GPIO-07 and GPIO-28 and see no issues whatsoever in toggling these lines. I'm attaching the modified files for your reference.

    -/Praneet

    1680.main.c
    //*****************************************************************************
    //
    // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
    //
    //
    //  Redistribution and use in source and binary forms, with or without
    //  modification, are permitted provided that the following conditions
    //  are met:
    //
    //    Redistributions of source code must retain the above copyright
    //    notice, this list of conditions and the following disclaimer.
    //
    //    Redistributions in binary form must reproduce the above copyright
    //    notice, this list of conditions and the following disclaimer in the
    //    documentation and/or other materials provided with the
    //    distribution.
    //
    //    Neither the name of Texas Instruments Incorporated nor the names of
    //    its contributors may be used to endorse or promote products derived
    //    from this software without specific prior written permission.
    //
    //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // Application Name     - Blinky
    // Application Overview - The objective of this application is to showcase the
    //                        GPIO control using Driverlib api calls. The LEDs
    //                        connected to the GPIOs on the LP are used to indicate
    //                        the GPIO output. The GPIOs are driven high-low
    //                        periodically in order to turn on-off the LEDs.
    // Application Details  -
    // http://processors.wiki.ti.com/index.php/CC32xx_Blinky_Application
    // or
    // docs\examples\CC32xx_Blinky_Application.pdf
    //
    //*****************************************************************************
    
    //****************************************************************************
    //
    //! \addtogroup blinky
    //! @{
    //
    //****************************************************************************
    
    // Standard includes
    #include <stdio.h>
    
    // Driverlib includes
    #include "hw_types.h"
    #include "hw_ints.h"
    #include "hw_memmap.h"
    #include "hw_common_reg.h"
    #include "interrupt.h"
    #include "hw_apps_rcm.h"
    #include "prcm.h"
    #include "rom.h"
    #include "rom_map.h"
    #include "prcm.h"
    #include "gpio.h"
    #include "utils.h"
    
    // Common interface includes
    #include "gpio_if.h"
    
    #include "pinmux.h"
    
    #define APPLICATION_VERSION     "1.1.1"
    
    //*****************************************************************************
    //                 GLOBAL VARIABLES -- Start
    //*****************************************************************************
    #if defined(ccs)
    extern void (* const g_pfnVectors[])(void);
    #endif
    #if defined(ewarm)
    extern uVectorEntry __vector_table;
    #endif
    //*****************************************************************************
    //                 GLOBAL VARIABLES -- End
    //*****************************************************************************
    
    
    //*****************************************************************************
    //                      LOCAL FUNCTION PROTOTYPES
    //*****************************************************************************
    void LEDBlinkyRoutine();
    static void BoardInit(void);
    
    //*****************************************************************************
    //                      LOCAL FUNCTION DEFINITIONS
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! Configures the pins as GPIOs and peroidically toggles the lines
    //!
    //! \param None
    //!
    //! This function
    //!    1. Configures 3 lines connected to LEDs as GPIO
    //!    2. Sets up the GPIO pins as output
    //!    3. Periodically toggles each LED one by one by toggling the GPIO line
    //!
    //! \return None
    //
    //*****************************************************************************
    void LEDBlinkyRoutine()
    {
        unsigned int gpio7Port, gpio28Port;
        unsigned char gpio7Pin, gpio28Pin;
    
        //
        // Toggle the lines initially to turn off the LEDs.
        // The values driven are as required by the LEDs on the LP.
        //
        GPIO_IF_LedOff(MCU_ALL_LED_IND);
    
        GPIO_IF_GetPortNPin(7, &gpio7Port, &gpio7Pin);
        GPIO_IF_GetPortNPin(28, &gpio28Port, &gpio28Pin);
        while(1)
        {
            #if 0
            //
            // Alternately toggle hi-low each of the GPIOs
            // to switch the corresponding LED on/off.
            //
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOn(MCU_RED_LED_GPIO);
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOff(MCU_RED_LED_GPIO);
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO);
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO);
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
            MAP_UtilsDelay(8000000);
            GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
            #endif
    
            MAP_UtilsDelay(8000000);
            GPIO_IF_Set(7, gpio7Port, gpio7Pin, 1);
            MAP_UtilsDelay(8000000);
            GPIO_IF_Set(7, gpio7Port, gpio7Pin, 0);
            MAP_UtilsDelay(8000000);
            GPIO_IF_Set(28, gpio28Port, gpio28Pin, 1);
            MAP_UtilsDelay(8000000);
            GPIO_IF_Set(28, gpio28Port, gpio28Pin, 0);
    
        }
    
    }
    //*****************************************************************************
    //
    //! Board Initialization & Configuration
    //!
    //! \param  None
    //!
    //! \return None
    //
    //*****************************************************************************
    static void
    BoardInit(void)
    {
    /* In case of TI-RTOS vector table is initialize by OS itself */
    #ifndef USE_TIRTOS
        //
        // Set vector table base
        //
    #if defined(ccs)
        MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    #endif
    #if defined(ewarm)
        MAP_IntVTableBaseSet((unsigned long)&__vector_table);
    #endif
    #endif
    
        //
        // Enable Processor
        //
        MAP_IntMasterEnable();
        MAP_IntEnable(FAULT_SYSTICK);
    
        PRCMCC3200MCUInit();
    }
    //****************************************************************************
    //
    //! Main function
    //!
    //! \param none
    //!
    //! This function
    //!    1. Invokes the LEDBlinkyTask
    //!
    //! \return None.
    //
    //****************************************************************************
    int
    main()
    {
        //
        // Initialize Board configurations
        //
        BoardInit();
    
        //
        // Power on the corresponding GPIO port B for 9,10,11.
        // Set up the GPIO lines to mode 0 (GPIO)
        //
        PinMuxConfig();
        GPIO_IF_LedConfigure(LED1|LED2|LED3);
    
        GPIO_IF_LedOff(MCU_ALL_LED_IND);
    
        //
        // Start the LEDBlinkyRoutine
        //
        LEDBlinkyRoutine();
        return 0;
    }
    
    //*****************************************************************************
    //
    // Close the Doxygen group.
    //! @}
    //
    //*****************************************************************************
    

    3580.pinmux.c
    //*****************************************************************************
    // pinmux.c
    //
    // configure the device pins for different peripheral signals
    //
    // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
    //
    //
    //  Redistribution and use in source and binary forms, with or without
    //  modification, are permitted provided that the following conditions
    //  are met:
    //
    //    Redistributions of source code must retain the above copyright
    //    notice, this list of conditions and the following disclaimer.
    //
    //    Redistributions in binary form must reproduce the above copyright
    //    notice, this list of conditions and the following disclaimer in the
    //    documentation and/or other materials provided with the
    //    distribution.
    //
    //    Neither the name of Texas Instruments Incorporated nor the names of
    //    its contributors may be used to endorse or promote products derived
    //    from this software without specific prior written permission.
    //
    //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //
    //*****************************************************************************
    
    // This file was automatically generated on 7/21/2014 at 3:06:20 PM
    // by TI PinMux version 3.0.334
    //
    //*****************************************************************************
    
    #include "pinmux.h"
    #include "hw_types.h"
    #include "hw_memmap.h"
    #include "hw_gpio.h"
    #include "pin.h"
    #include "rom.h"
    #include "rom_map.h"
    #include "gpio.h"
    #include "prcm.h"
    
    //*****************************************************************************
    void
    PinMuxConfig(void)
    {
        //
        // Enable Peripheral Clocks
        //
        MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
        MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
        MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
    
        //
        // Configure PIN_64 for GPIOOutput
        //
        MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
        MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
    
        //GPIO-07
        MAP_PinTypeGPIO(PIN_62, PIN_MODE_0, false);
        MAP_GPIODirModeSet(GPIOA0_BASE, 0x80, GPIO_DIR_MODE_OUT);
    
        //GPIO-28
        MAP_PinTypeGPIO(PIN_18, PIN_MODE_0, false);
        MAP_GPIODirModeSet(GPIOA3_BASE, 0x10, GPIO_DIR_MODE_OUT);
    
        //
        // Configure PIN_01 for GPIOOutput
        //
        MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
        MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);
    
        //
        // Configure PIN_02 for GPIOOutput
        //
        MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
        MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);
    }