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.

CCS/TMS320F28379D: Not able to read Digital Input.

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi,

I am using hardware loop on the dock for GPIO 12 as Digital Input and GPIO 14 as Digital Output and later on using two loops for with condition. Function is not working. Please help me to know my error in the code..

######################################################################################## Code:

#include "F28x_Project.h"
#define BLINKY_LED_GPIO 12
void main(void)
{

InitSysCtrl();
InitGpio();
GPIO_SetupPinMux(BLINKY_LED_GPIO, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(BLINKY_LED_GPIO, GPIO_INPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(31, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(34, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(34, GPIO_OUTPUT, GPIO_PUSHPULL);
GPIO_SetupPinMux(14, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(14, GPIO_OUTPUT, GPIO_PUSHPULL);
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EINT;
ERTM;

GPIO_WritePin(14,0);

if (BLINKY_LED_GPIO==1)
{
     for(;;)
    {
      GPIO_WritePin(34, 0);
      DELAY_US(1000*500);
      GPIO_WritePin(34, 1);
      DELAY_US(1000*500);
     }
}
else
{
     for(;;)
     {
     GPIO_WritePin(31, 0);
     DELAY_US(1000*500);
     GPIO_WritePin(31, 1);
     DELAY_US(1000*500);
     }

}
}

//
// End of file
//

The output of the program gives always blinking of LED 31 on control card.

### Does it require an additional line to read DI..?

Thanks and Regards,

Rahul Sharma 

  • In order to read a GPIO use GPIO_read* API's from the GPIO driverlib.

    something like read_var = GPIO_read...(12) and then use that variable to make a decision.

  • Hii

    Thanks for Support...!!!

    Tried Doing this. It's still not working. Please let me know my mistake..

    ################################################################# Code...

    #include "F28x_Project.h"
    #define BLINKY_LED_GPIO 12

    void main(void)
    {

    int read_var;
    InitSysCtrl();
    InitGpio();
    GPIO_SetupPinMux(BLINKY_LED_GPIO, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(BLINKY_LED_GPIO, GPIO_INPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(31, GPIO_OUTPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(34, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(34, GPIO_OUTPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(14, GPIO_MUX_CPU1, 0);
    GPIO_SetupPinOptions(14, GPIO_OUTPUT, GPIO_PUSHPULL);
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;
    ERTM;

    GPIO_WritePin(14,0);
    read_var = GPIO_ReadPin(BLINKY_LED_GPIO);

    if (read_var == 1)
    {
    for(;;)
    {
    GPIO_WritePin(34, 0);
    DELAY_US(1000*500);
    GPIO_WritePin(34, 1);
    DELAY_US(1000*500);
    }
    }
    else
    {
    for(;;)
    {
    GPIO_WritePin(31, 0);
    DELAY_US(1000*500);
    GPIO_WritePin(31, 1);
    DELAY_US(1000*500);
    }
    }
    }

    //
    // End of file
    //

    Can you please share a code to read digital input...?

    Thanks and Regards,

    Rahul Sharma

  • I do not see what you have inside of initGpio() routine. Most likely you might be configuring GPIO to be mapped to some other peripheral.

    It should ideally be GPIO_setPinConfig(GPIO_x_GPIOx);   which makes Pin-x to be configured as GPIO.

    Then you should configure whether its an input or output and other configs,

    There are bunch of examples in c2000ware please refer to the same

    .....\C2000Ware_3_02_00_00\driverlib\f2837xs\examples\cpu1\gpio

  • Hi..

    Thanks For the Reply...!!!

    When i was looping DO and DI with hardware it was not working as DO is sinking type but when i connected DI directly to 3.3V it works fine.

    Thanks,

    Rahul Sharma