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 Programming in TMS320C6748

Other Parts Discussed in Thread: TMS320C6748

Hi,

1)      We have a custom built board. The processor used is TMS320C6748. I want to use PIN No-3 of PORT No-3. It should detect a change in edge. I did little modification in the GPIO Example code provided in the ‘pspiom’ of 6748. The code complies but does not detect any change in edge(falling or rising). Can you please go through the code and help me out.

2)      The DSP/BIOS API provided in ‘TMS320C6000 DSP/BIOS 5.x Application Programming Interface Reference Guide’ are different to the one used in this program.

3)      I am confused as no where I am finding a simple standard code just do simple programs like GPIO,SPI,UART and etc (we get them very easily for PIC microcontrollers and etc.).

 

/* gpioSample_main.c */ [The main Code]

#include <std.h>

#include <sys.h>

#include <pwrm.h>

#include <pwrm6748.h>

 

#include "ti/pspiom/gpio/Gpio.h"

 

Gpio_Handle     gpio0;

 

#define GPIO_BANK_0 0x00

#define GPIO_BANK_3                 3u

#define GPIO0_3_PIN                 51u

Void main (Void)

{

    Gpio_Params     gpioParams = Gpio_PARAMS;

 

    /* update the gpio parameters to our needs */

 

    gpioParams.instNum = 0;

    gpioParams.BankParams[GPIO_BANK_0].inUse = Gpio_InUse_No;

    gpioParams.BankParams[GPIO_BANK_0].hwiNum  = 8u;

    gpioParams.BankParams[GPIO_BANK_0].PinConfInfo[0].inUse = Gpio_InUse_No;

 

    /* open the GPIO driver to get a handle to it */

    gpio0 = Gpio_open(&gpioParams);

    /* power on the GPIO device in the Power sleep controller                 */

    /* Power on using Bios PWRM API                                           */

    PWRM_setDependency(PWRM_RSRC_GPIO);

   

    return;

}

 

/* gpioSample_io.c */ [The helping Code]

#include <std.h>

#include <iom.h>     

#include <log.h>

#include <tsk.h>    

#include "ti/pspiom/cslr/cslr_gpio.h"

#include "ti/pspiom/cslr/cslr_syscfg0_C6748.h"

#include "ti/pspiom/cslr/soc_C6748.h"

#include "ti/pspiom/gpio/Gpio.h"

#include "ti/pspiom/platforms/evm6748/gpio_evmInit.h"

extern LOG_Obj trace;

volatile Int32 flag = 0;

extern Gpio_Handle     gpio0;

#define LOW 0x0

#define HIGH 0x1

#define GPIO_BANK_0 0x00

#define GPIO_BANK_3                 3u

#define GPIO0_3_PIN                 51u 

Void gpioInputIsr(Ptr); 

Void delay(Void)

{

    volatile Int32 i,j;

      for(i=0; i<5000; i++)

      {

          for(j=0; j<5000; j++)

          {

              ;

          }

      }

}

 

//GPIO_BANK_3

Void gpioExampleTask(Void)

{

    Gpio_PinCmdArg  pinCmdArg;

    Gpio_IntrCmdArg intrCmdArg;

 

    /* Configure GPIO(GPIO3_3_PIN) as an input                                */

    pinCmdArg.pin   = GPIO0_3_PIN;

    pinCmdArg.value = Gpio_Direction_Input;

    Gpio_setPinDir(gpio0, &pinCmdArg);

 

    /* Enable GPIO Bank interrupt for bank GPIO_BANK_3                        */

    Gpio_bankInterruptEnable(gpio0, GPIO_BANK_3);

 

    /* Configure GPIO(GPIO3_3_PIN) to generate interrupt on rising edge       */

    Gpio_setRisingEdgeTrigger(gpio0, GPIO0_3_PIN);

 

    /* Configure GPIO(GPIO3_3_PIN) to generate interrupt on falling edge      */

    Gpio_setFallingEdgeTrigger(gpio0, GPIO0_3_PIN);

 

    /* Set the interrupt handler for GPIO3_3_PIN. However we cannot register

     * interrupts for individual pins in C6748, therefore  register interrupt

     * for the associated bank(BANK4) as a whole

     */

    intrCmdArg.value = GPIO_BANK_3;

    intrCmdArg.bankOrPin = Gpio_BankOrPin_isBank;

    intrCmdArg.isrHandler = (Gpio_Isr)gpioInputIsr;

    Gpio_regIntHandler(gpio0, &intrCmdArg);

 

    /*At GPIO3_0_PIN bit value of 1 at the input reg represents that the card

    is removed and 0 means it is inserted*/

 

    LOG_printf(&trace, "Waiting for GPIO Interrupt\n");

    LOG_printf(&trace, "Waiting for GPIO Interrupt\n");

    while( 0 == flag)

    {

        TSK_sleep(2000);

        LOG_printf(&trace, "Waiting for user to Insert MMCSD card\n");

    }

 

    LOG_printf(&trace, "GPIO Interrupt occured !\n");

 

    /* close the GPIO driver handle */

    Gpio_close(gpio0);

 

    LOG_printf(&trace, "End of GPIO sample application!\n");

}

 

 

Void gpioInputIsr(Ptr ignore)

{

    Gpio_PinCmdArg  pinCmdArg;

 

    /* To avoid compiler warnings                                             */

    ignore = ignore;

    /* Clear the interrupt status                                             */

    pinCmdArg.pin   = GPIO0_3_PIN;

    Gpio_clearInterruptStatus(gpio0,&pinCmdArg);

 

    flag=1;          

}

  • Sandy,

    I am afraid we can't review bios examples in this forum. Here is what I will suggest:

    1. make sure the pin is powered on - if you write to it inside CCS as an output, you should see toggling.

    2. make sure when you drive it, you see the status of that pin change inside CCS

    3. if you are using interrupt, make sure you are setting up interrupt correctly (both inside GPIO module and DSP interrupt controller).

    regards,

    Paul

  • Double-check the pin muxing is configured correctly for the specific pin you're using, i.e. PINMUX8[19:16] = 0x8.