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.

How to blink inerfaced LED at GPIO Expansion of C6748 LCDK?

Other Parts Discussed in Thread: OMAPL138, TMS320C6748

Dear Community,

By the below program I can blink on board LED .


int main(void)
{

   PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,PSC_MDCTL_NEXT_ENABLE);
    GPIOBank6Pin13PinMuxSetup();
   GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT);

    while(1)
    {
  GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);

  Delay(10000);

  GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);

  Delay(10000);
    }

}

1.                If I want to blink a LED out of board.  What are the pins available ?

2.                Can I use J15 GPIIO8-12 or GPIO8-10??

3.               When I am using the function for GPIIO8-12.

GPIOBank8Pin16PinMuxSetup();

  It is showing  error  

Description Resource Path Location Type unresolved symbol GPIOBank8Pin16PinMuxSetup, first referenced in ./main.obj gpio_c674x_c6748_lcdkC6748    C/C++ Problem

4.  From where I will get the pin numbers, multiplexing pin numbers and bank number ?? For LED blinking these datas are required.

AS LED  D4= PIN-110 bANK 6 multuplexing Pin 13.

LED D5 =Pin -109 Bank 6 multuplexing Pin 12

 How to get the Pin Bank  of LED D6, D7, D8???

With regards,

AS

  • Hi Amlan,
    Here is the code for doing PINMUX for various GPIOs (LED & Switch) on LCDK board.

    /**

    * \file gpio_switches_leds.c

    *

    * \brief This is a sample application file demonstrating the use of

    * a GPIO pin for input and output

    *

    *

    * Copyright (C) 2012 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.

    */


    #include<stdio.h>


    #include "gpio.h"

    #include "psc.h"


    #include "soc_OMAPL138.h"

    #include "lcdkOMAPL138.h"


    /* HW Macros */

    #include "hw_types.h"


    /* System Defines */

    #include "lcdkOMAPL138.h"

    #include "soc_OMAPL138.h"

    #include "hw_syscfg0_OMAPL138.h"




    /* Switch Configuration */


    /* GP0[1] to GP0[4] is mapped to SW1[3:4] on OMAPL138/C6748 LCDK boards */


    /* Pin Multiplexing bit mask to select GP0[1] to GP0[4] pin. */


    #define PINMUX1_GPIO0_1_ENABLE (SYSCFG_PINMUX1_PINMUX1_27_24_GPIO0_1 << \

    SYSCFG_PINMUX1_PINMUX1_27_24_SHIFT)


    #define PINMUX1_GPIO0_2_ENABLE (SYSCFG_PINMUX1_PINMUX1_23_20_GPIO0_2 << \

    SYSCFG_PINMUX1_PINMUX1_23_20_SHIFT)


    #define PINMUX1_GPIO0_3_ENABLE (SYSCFG_PINMUX1_PINMUX1_19_16_GPIO0_3 << \

    SYSCFG_PINMUX1_PINMUX1_19_16_SHIFT)


    #define PINMUX1_GPIO0_4_ENABLE (SYSCFG_PINMUX1_PINMUX1_15_12_GPIO0_4 << \

    SYSCFG_PINMUX1_PINMUX1_15_12_SHIFT)



    /* LED Configuration */


    /* GP6[12], GP6[13], GP2[12] and GP0[9] is mapped to D4, D5, D6, D7 LEDs on OMAPL138/C6748 LCDK boards */


    /* Pin Multiplexing bit mask to select GP6[12] pin. */

    #define PINMUX13_GPIO6_12_ENABLE (SYSCFG_PINMUX13_PINMUX13_15_12_GPIO6_12 << \

    SYSCFG_PINMUX13_PINMUX13_15_12_SHIFT)


    /* Pin Multiplexing bit mask to select GP6[13] pin. */

    #define PINMUX13_GPIO6_13_ENABLE (SYSCFG_PINMUX13_PINMUX13_11_8_GPIO6_13 << \

    SYSCFG_PINMUX13_PINMUX13_11_8_SHIFT)


    /* Pin Multiplexing bit mask to select GP2[12] pin. */

    #define PINMUX5_GPIO2_12_ENABLE (SYSCFG_PINMUX5_PINMUX5_15_12_GPIO2_12 << \

    SYSCFG_PINMUX5_PINMUX5_15_12_SHIFT)


    /* Pin Multiplexing bit mask to select GP0[9] pin. */

    #define PINMUX0_GPIO0_9_ENABLE (SYSCFG_PINMUX0_PINMUX0_27_24_GPIO0_9 << \

    SYSCFG_PINMUX0_PINMUX0_27_24_SHIFT)



    void PinMuxSetup_leds(void)

    {

    unsigned int savePinmux = 0;



    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX13 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) &

    ~(SYSCFG_PINMUX13_PINMUX13_15_12));


    /* Setting the pins corresponding to GP6[12] in PINMUX13 register.*/

    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) =

    (PINMUX13_GPIO6_12_ENABLE | savePinmux);



    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX13 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) &

    ~(SYSCFG_PINMUX13_PINMUX13_11_8));


    /* Setting the pins corresponding to GP6[13] in PINMUX13 register.*/

    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) =

    (PINMUX13_GPIO6_13_ENABLE | savePinmux);



    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX5 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) &

    ~(SYSCFG_PINMUX5_PINMUX5_15_12));


    /* Setting the pins corresponding to GP2[12] in PINMUX5 register.*/

    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) =

    (PINMUX5_GPIO2_12_ENABLE | savePinmux);



    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX0 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(0)) &

    ~(SYSCFG_PINMUX0_PINMUX0_27_24));


    /* Setting the pins corresponding to GP0[9] in PINMUX0 register.*/

    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(0)) =

    (PINMUX0_GPIO0_9_ENABLE | savePinmux);


    }




    void PinMuxSetup_switches(void)

    {

    unsigned int savePinmux = 0;


    /* Setting the pins corresponding to GP0[1] in PINMUX1 register.*/


    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX1 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) &

    ~(SYSCFG_PINMUX1_PINMUX1_27_24));



    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) =

    (PINMUX1_GPIO0_1_ENABLE | savePinmux);




    /* Setting the pins corresponding to GP0[2] in PINMUX1 register.*/


    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX1 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) &

    ~(SYSCFG_PINMUX1_PINMUX1_23_20));



    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) =

    (PINMUX1_GPIO0_2_ENABLE | savePinmux);





    /* Setting the pins corresponding to GP0[3] in PINMUX1 register.*/


    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX1 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) &

    ~(SYSCFG_PINMUX1_PINMUX1_19_16));



    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) =

    (PINMUX1_GPIO0_3_ENABLE | savePinmux);




    /* Setting the pins corresponding to GP0[4] in PINMUX1 register.*/


    /*

    ** Clearing the bit in context and retaining the other bit values

    ** in PINMUX1 register.

    */

    savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) &

    ~(SYSCFG_PINMUX1_PINMUX1_15_12));



    HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) =

    (PINMUX1_GPIO0_4_ENABLE | savePinmux);



    }



    int main(void)

    {



    /* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/

    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,

    PSC_MDCTL_NEXT_ENABLE);



    /* Pin Multiplexing of pins GP0[1] to GP0[4] of GPIO Bank 2 for DIP SWITCHEs in OMAPL138 LCDK board */

    PinMuxSetup_switches();


    /* Pin Multiplexing of pins GP6[12], GP6[13], GP2[12], GP0[9], for LEDs in OMAPL138 LCDK board */

    PinMuxSetup_leds();



    /* 2,3,4,5 is the GPIO no for GP0[1] to GP0[4]; Refer page no 901 in OMAPL138/C6748 TRM */



    /* SWITCHEs SETUP */


    /* Sets the pin 2 (GP0[1]) as input.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 2, GPIO_DIR_INPUT);


    /* Sets the pin 3 (GP0[2]) as input.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 3, GPIO_DIR_INPUT);


    /* Sets the pin 4 (GP0[3]) as input.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 4, GPIO_DIR_INPUT);


    /* Sets the pin 5 (GP0[4]) as input.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 5, GPIO_DIR_INPUT);


    /* LEDs SETUP */


    /* Sets the pin 109 (GP6[12]) as output.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT);


    /* Sets the pin 110 (GP6[13]) as output.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT);


    /* Sets the pin 45 (GP2[12]) as output.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 45, GPIO_DIR_OUTPUT);


    /* Sets the pin 10 (GP0[9]) as output.*/

    GPIODirModeSet(SOC_GPIO_0_REGS, 10, GPIO_DIR_OUTPUT);



    while(1)

    {


    /* 2,3,4,5 is the GPIO no for GP0[1] to GP0[4]; Refer page no 901 in OMAPL138/C6748 TRM */


    if (GPIOPinRead(SOC_GPIO_0_REGS, 2))

    {


    GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_LOW);

    printf("S1 is not pressed\n");


    }


    else

    {

    printf("S1 is pressed\n");

    GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_HIGH);


    }


    if (GPIOPinRead(SOC_GPIO_0_REGS, 3))

    {


    GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW);

    printf("S2 is not pressed\n");


    }

    else

    {

    printf("S2 is pressed\n");

    GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH);


    }



    if (GPIOPinRead(SOC_GPIO_0_REGS, 4))

    {


    GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);

    printf("S3 is not pressed\n");


    }

    else

    {

    printf("S3 is pressed\n");

    GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);


    }



    if (GPIOPinRead(SOC_GPIO_0_REGS, 5))

    {


    GPIOPinWrite(SOC_GPIO_0_REGS, 10, GPIO_PIN_LOW);

    printf("S4 is not pressed\n");



    }

    else

    {

    printf("S4 is pressed\n");

    GPIOPinWrite(SOC_GPIO_0_REGS, 10, GPIO_PIN_HIGH);


    }




    }



    }
  • Hi Amlan,
    Able to blink the GPIO successfully ?
    Can you please update ?
  • Hello Shankari,

    I have implemented same code on TMS320C6748 LCDK DSP processor.

    Additional info: Windows 7 64-bit, Service Pack 1, Code Composer Studio Version: 6.0.1.00040.

    But I am facing issues.

    Please find attached  word file of screenshots of same program which I executed on CCS.
    I think I may be missing some support file or may have  copied the code incorrectly. This is because there are splits in the lines of code and I am not sure whether I have interpreted them correctly. 
    Could you please take a look at it and help me to sort this issue.GPIO program.docx
    Thanks,
    Onkar