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: Configure GPIOXX general purpose output

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello

i want measure the ISR loop exqution time by using some i/o pin

so i Configure GPIO52 is like this is it correct or not.

EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up on GPIO2 (EPWM1A)
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pull-up on GPIO2 (EPWM2A)
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO2 as EPWM1A
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // Configure GPIO2 as EPWM2A
GpioCtrlRegs.GPDATA.bit.GPIO52 = 1;
EDIS;

......

...

__interrupt void epwm1_isr(void)
{
//*Here my code assign a new sin value into compare reg. but negative side of sin wave pwm //logic is invertered.*/

a1=sin(PI*0.02*i1);
GpioDataRegs.GPBDAT.bit.GPIO52 = 0;
if (a1>=0)
{
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Set PWM1A on event A, up
EPwm1Regs.AQCTLA.bit.CAD =AQ_SET; // Clear PWM1A on event B, down
EPwm1Regs.CMPA.bit.CMPA =b1[i1];
}
else
{
EPwm1Regs.AQCTLA.bit.CAU =AQ_SET; // Set PWM1A on event A, up
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on event B, down
EPwm1Regs.CMPA.bit.CMPA =b1[i1];
}
i1++;
if (i1==401)
{
i1=0;
}
EPwm1Regs.ETCLR.bit.INT = 1;

PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}

__interrupt void epwm2_isr(void)
{
//*Here my code assign a new sin value into compare reg. but negative side of sin wave pwm //logic is invertered.*/

a2=sin(PI*0.02*i2);
if (a2>=0)
{
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Set PWM2A on event A, up
EPwm2Regs.AQCTLA.bit.CAD =AQ_SET; // Clear PWM2A on event B, down
EPwm2Regs.CMPA.bit.CMPA =b2[i2];
}
else
{
EPwm2Regs.AQCTLA.bit.CAU =AQ_SET; // Set PWM2A on event A, up
EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM2A on event B, down
EPwm2Regs.CMPA.bit.CMPA =b2[i2];
}
i2++;
if (i2==401)
{
i2=0;
}
EPwm2Regs.ETCLR.bit.INT = 1;

PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
GpioDataRegs.GPBDAT.bit.GPIO52 = 1;
}

  • Hi,

    Couple of observations -

    GpioCtrlRegs.GPDATA.bit.GPIO52 = 1;

    I think you want to change the direction of this pin as output and for that you need to write into ...DIR register.

    GpioCtrlRegs.GPBDIR.bit.GPIO52 = 1;

    Inside ISR, to change the state of pin, we recommend using SET (to have value '1' on pin) and CLEAR (to have value '0' on pin) registers instead of DAT register. DAT register should be used to READ the state of pin.

    Regards,

    Vivek Singh

  • Hi Nageshwar,
    Everything looks perfect except for the first highlighted part of the code:

    GpioCtrlRegs.GPDATA.bit.GPIO52 = 1;

    Instead of this, you should be setting the GPIO direction to output. So your code will change to this:

    GpioCtrlRegs.GPBDIR.bit.GPIO52 = 1;

    Until you set the direction of a pin to output, your changes to the DATA registers are locked in latch only. They are not reflected on the pin.
    For more information on setting up and using a GPIO pin, you can refer to C2000Ware_1_00_xx_00\device_support\f2837xd\examples\cpu1\gpio_setup\cpu01\GpioSetup.c

    You can download the latest version of C2000Ware here: www.ti.com/.../c2000ware
  • thank you 

    i got it...