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.

Issue with trying to blink an external LED

HI 

I am using the Launchxl F28379D board.I am trying to blink an external LED using Gpio6 , with this code I am able to blink the code on the board but was not able to blink the external led which is connected to pin80 (GPIO6). 

Can some one please mention what is the reason for it? Why the same code works for the on board LED but is not able to make the GPIO6 high?

Attached is the code. 

Kind Regards

Sana 


#include "F28x_Project.h"


#define BLINKY_LED_GPIO 31
#define BLINKY_LED_GPIO6 80

main()
{
int x = 0;
int alarm = 0;

InitSysCtrl();
//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
InitGpio();
GPIO_SetupPinMux(BLINKY_LED_GPIO, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(BLINKY_LED_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);

GPIO_SetupPinMux(BLINKY_LED_GPIO6, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(BLINKY_LED_GPIO6, GPIO_OUTPUT, GPIO_PUSHPULL);


while (x<1000)
//while(1)
{
if(alarm==1000)
{
GPIO_WritePin(BLINKY_LED_GPIO, 1);
//EALLOW;
//GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup on GPIO6
//GpioDataRegs.GPASET.bit.GPIO6 = 1; // Load output latch
//GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO6 = GPIO6
//GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO6 = output
//EDIS;
GPIO_WritePin(BLINKY_LED_GPIO6, 1);
continue;
}
x = x + 1;
GPIO_WritePin(BLINKY_LED_GPIO, 0);

}

while(2);

}

  • Hi, 

    GPIO31 is connected to the LED and hence it works fine. 

     How did you determine that GPIO6 is defined as 80? "#define BLINKY_LED_GPIO6 80"

    Best Regards

    Siddharth

  • HI Siddharth

    The GPIO6 is shown to be connected to PIN 80 (J8) as shown in the picture below. My assumption is based on this datasheet.

    Kind Regards

    Sana 

  • Sana, 

    If you look at the function definitions , the first argument to the GPIO_SetupPinMux, GPIO_SetupPinOptions and GPIO_WritePin is the gpioNumber and not the pin number.  Hence you can change it to GPIO6 and try.

    Also, the snapshot that you shared indicates that GPIO6 is connected to pin80 on the LaunchPad and not of the device.  

    Best Regards

    Siddharth

  • HI Siddharth

    I changed the name the code by replacing the GPIO pi number with GPIO6 and its still not blinking an external LED. Attached is the code. 

    Also I did not get what you mean by the the sentence "Also, the snapshot that you shared indicates that GPIO6 is connected to pin80 on the LaunchPad and not of the device.". I am not sure what you mean "not of the device. I am using Launchpad F28379D.

    Kind Regards

    Sana 


    #include "F28x_Project.h"


    #define BLINKY_LED_GPIO 31
    //#define GPIO6

    main()
    {
    int x = 0;
    int alarm = 0;

    InitSysCtrl();
    //
    // Step 2. Initialize GPIO:
    // This example function is found in the F2837xD_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    //
    InitGpio();
    GPIO_SetupPinMux(BLINKY_LED_GPIO, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(BLINKY_LED_GPIO, GPIO_OUTPUT, GPIO_PUSHPULL);
    //InitGpio();
    GPIO_SetupPinMux(GPIO6, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(GPIO6, GPIO_OUTPUT, GPIO_PUSHPULL);


    while (x<1000)
    //while(1)
    {
    if(alarm==1000)
    {
    GPIO_WritePin(BLINKY_LED_GPIO, 1);
    //EALLOW;
    //GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup on GPIO6
    //GpioDataRegs.GPASET.bit.GPIO6 = 1; // Load output latch
    //GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO6 = GPIO6
    //GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO6 = output
    //EDIS;
    GPIO_WritePin(GPIO6, 0);
    continue;
    }
    x = x + 1;
    GPIO_WritePin(BLINKY_LED_GPIO, 0);

    }

    while(2);

    }

  • Hi, 

    Can you try using  the following code ?

    #define BLINKY_LED_GPIO6 6

    You can also see the register view in CCS and see if the correct registers corresponding to GPIO are set.

    Best Regards

    Siddharth 

  • HI Siddharth

    It works now, thank you very much for your help.

    Kind Regards

    Sana