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.

TMS320F28374S: HOW TO REDUCE THE EXECUTION TIME IN PROJECTS BUILD FROM DEVICE SUPPORT.

Part Number: TMS320F28374S
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi Everybody 

As you can see in the picture, I have two projects named as demo2 and demo3. I am currently using TMS320F28374S microcontroller for my project.  As stated in the documentation i have developed two projects one from driverlib and other from the device support to do same task. When I build from the demo2 (driverlib) the toggling of GPIO26 takes place at every 6 u-Sec and when i build from the demo3 (device support) takes 40 u-Sec.

I want to know why running the same function on same hardware is taking so much different time. I want to know what is the mistake i am doing in configuring the demo3 project. I have followed every instruction in the document  F2837xS_FRM_EX_UG to configure the project.

This is the code written for InitSysCtrl function in F2837xS_SysCtrl.c file. 

void InitSysCtrl(void)
{
//
// Disable the watchdog
//
DisableDog();

#ifdef _FLASH
//
// Copy time critical code and Flash setup code to RAM. This includes the
// following functions: InitFlash()
//
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

//
// Call Flash Initialization to setup flash waitstates. This function must
// reside in RAM.
//
InitFlash_Bank0();
#endif

//
// *IMPORTANT*
//
// The Device_cal function, which copies the ADC & oscillator calibration
// values from TI reserved OTP into the appropriate trim registers, occurs
// automatically in the Boot ROM. If the boot ROM code is bypassed during
// the debug process, the following function MUST be called for the ADC and
// oscillators to function according to specification. The clocks to the
// ADC MUST be enabled before calling this function.
//
// See the device data manual and/or the ADC Reference Manual for more
// information.
//
EALLOW;

//
// Enable pull-ups on unbonded IOs as soon as possible to reduce power
// consumption.
//
GPIO_EnableUnbondedIOPullups();

CpuSysRegs.PCLKCR13.bit.ADC_A = 1;
CpuSysRegs.PCLKCR13.bit.ADC_B = 1;
CpuSysRegs.PCLKCR13.bit.ADC_C = 1;
CpuSysRegs.PCLKCR13.bit.ADC_D = 1;

//
// Check if device is trimmed
//
if(*((Uint16 *)0x5D1B6) == 0x0000){
//
// Device is not trimmed--apply static calibration values
//
AnalogSubsysRegs.ANAREFTRIMA.all = 31709;
AnalogSubsysRegs.ANAREFTRIMB.all = 31709;
AnalogSubsysRegs.ANAREFTRIMC.all = 31709;
AnalogSubsysRegs.ANAREFTRIMD.all = 31709;
}

CpuSysRegs.PCLKCR13.bit.ADC_A = 0;
CpuSysRegs.PCLKCR13.bit.ADC_B = 0;
CpuSysRegs.PCLKCR13.bit.ADC_C = 0;
CpuSysRegs.PCLKCR13.bit.ADC_D = 0;
EDIS;

//
// Initialize the PLL control: SYSPLLMULT and SYSCLKDIVSEL.
//
// Defined options to be passed as arguments to this function are defined
// in F2837xS_Examples.h.
//
// Note: The internal oscillator CANNOT be used as the PLL source if the
// PLLSYSCLK is configured to frequencies above 194 MHz.
//
// PLLSYSCLK = (XTAL_OSC) * (IMULT + FMULT) / (PLLSYSCLKDIV)
//
#ifdef _LAUNCHXL_F28377S
InitSysPll(XTAL_OSC,IMULT_40,FMULT_0,PLLCLK_BY_2);
#else
InitSysPll(XTAL_OSC,IMULT_20,FMULT_0,PLLCLK_BY_2);
#endif

//
// Turn on all peripherals
//
InitPeripheralClocks();
}

the code written in main.c of demo2 (driverlib) is as follow:

#include "main.h"

float T;
PLL_DATATYPE grid_volt;

int main(void)
{
Device_init();
Interrupt_initModule();
Interrupt_initVectorTable();
Interrupt_enableMaster();
InitializeGPIO();

EINT;
ERTM;

while(1)
{
GPIO_writePin(26, 1);
PLL(&grid_volt,T);
PLL(&grid_volt,T);
GPIO_writePin(26, 0);

}
}

The code written in main.c of demo3 (device support) is as follow:

#include <F28x_Project.h>
#include "main.h"

float T;
PLL_DATATYPE grid_volt;
int main(void )
{
InitSysCtrl(); // System Initialization
EALLOW;
GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0; // GPIO34 as GPIO
GpioCtrlRegs.GPAGMUX2.bit.GPIO26 = 0; // GPIO34 as GPIO
GpioCtrlRegs.GPADIR.bit.GPIO26 = 1; // Direct GPIO as output
EDIS;
while(1)
{
GpioDataRegs.GPATOGGLE.bit.GPIO26 = 1;
PLL(&grid_volt,T);
GpioDataRegs.GPATOGGLE.bit.GPIO26 = 1;
}

}

Thank you in advance.

  • Hello,

    Firstly, it looks like you are not performing the same exact function between the two examples. In one, you are writing the GPIO high before PLL and writing low after. The other, you are toggling the GPIO to its opposite state. Also, using driverlib would take more cycles than writing directly to the register in bitfield- you can check the disassembly code and compare between the two. Also, is there a reason you have two PLL calls in one project, but one PLL call in the other?

    Best Regards,

    Allison

  • First of all thank you Allison,

    YES you have correctly noticed about two PLL calls. that is my mistake.

    In single PLL call in both the project, the driverlib is taking 3 u-Sec and device support is taking 20 u-Sec. The driver lib is very fast in this case. The toggling GPIO and directly writing to register in bitfield should not have such large difference.

    I am assuming I may have not correctly configured the  system PLL (not the function) i.e. InitSysCtrl(void) in the decive support example. Can you Please check that.?

    How can i check the disassembly code ? 

    Thanks 

  • Hi Abhinav,

    I agree the time difference should not be large. You can check the disassembly by going to the CCS tool bar and selecting "view" > "disassembly". This should open the correct window and you can compare between the two. 

    Are you referring to our C2000ware examples? If yes, the device initialization should be set up in the main already in either case (driverlib or bitfield). 

    Best Regards,

    Allison

  • Hi Allison,

    The problem is solved by adding a Symbol "_FLASH" in the  pre-defined symbol section. Now both the project are taking same time (there may be some difference in few n-sec which i don't mind ).

    Thank you for your help.