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.

Help figuring out F28335 cycle time problem

Other Parts Discussed in Thread: UCD3138

Hi,

I am encountering something that is a bit baffling and am hoping someone could clarify.

I am running a bit of code in an interruption and it is taking longer than I am expecting to execute when I check on my oscilloscope   I also checked using the clock feature in debugger mode to see how many clock cycles it is taking to execute an instruction, which I have included in the comments.  This is the code in question:

// Interrupt routines uses in this example:
#pragma CODE_SECTION(epwm_timer_isr, "ramfuncs");
interrupt void epwm_timer_isr(void)
{
   //EPwmTimerIntCount++;
	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns
	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns
	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns
	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns

	aux = GpioDataRegs.GPCDAT.all;         //3 cycles - 86ns

	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns
	GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1; //1 cycle - 49ns

   // Clear INT flag for this timer
   EPwm1Regs.ETCLR.bit.INT = 1;

   // Acknowledge this interrupt to receive more interrupts from group 3
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}

I am running this code off of RAM after transferring from FLASH.  I also checked running only from RAM and the behavior is the same.  I have also checked putting that bit of code directly into the main loop and disabling the interrupts and the behavior is the same.  I would expect to see the time it takes to toggle on and off that pin should be about 7ns.  Can anyone help me figure out what may be going on?

I am including more code so you can see how I have setup the main portion:

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
interrupt void epwm_timer_isr(void);


#define FLASH 1

#define CPU_CLOCK_HZ     150000000UL
#define wait_usec(us) DSP28x_usDelay((us)*(CPU_CLOCK_HZ/1000000UL/5)-2)

// Global variables used in this example
Uint32  EPwmTimerIntCount;
int aux;
float x = 1;
float w = 0.35;
float z = 2.5;

int main(void) {
	// Step 1. Initialize System Control:
	// PLL, WatchDog, enable Peripheral Clocks
	// This example function is found in the DSP2833x_SysCtrl.c file.
	   InitSysCtrl();

	// Step 2. Initalize GPIO:
	// This example function is found in the PTEL2_Gpio.c file and
	// illustrates how to set the GPIO to it's default state.
	   InitGpio();

	// Step 3. Clear all interrupts and initialize PIE vector table:
	// Disable CPU interrupts
	   DINT;

	// Initialize the PIE control registers to their default state.
	// The default state is all PIE interrupts disabled and flags
	// are cleared.
	// This function is found in the DSP2833x_PieCtrl.c file.
	   InitPieCtrl();

	// Disable CPU interrupts and clear all CPU interrupt flags:
	   IER = 0x0000;
	   IFR = 0x0000;

	// Initialize the PIE vector table with pointers to the shell Interrupt
	// Service Routines (ISR).
	// This will populate the entire table, even if the interrupt
	// is not used in this example.  This is useful for debug purposes.
	// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
	// This function is found in DSP2833x_PieVect.c.
	   InitPieVectTable();

#ifdef FLASH
	// Section ramfuncs contains user defined code that runs from RAM
	   memcpy(&ramfuncs_runstart, &ramfuncs_loadstart, (Uint32)&ramfuncs_loadsize);

	//--- Initialize the Flash and OTP
	   InitFlash();						// Initialize the Flash
#endif //(FLASH)

	// ISR functions found within this file.
	   EALLOW;  // This is needed to write to EALLOW protected registers
	   PieVectTable.EPWM1_INT = &epwm_timer_isr;
	   EDIS;    // This is needed to disable write to EALLOW protected registers

	// Initialize the PWM
	   InitEPwm();

	// Initalize counters:
	   EPwmTimerIntCount = 0;

	// Step 4. User specific code, enable interrupts:
	// Enable CPU INT3 which is connected to EPWM1-6 INT:
	   IER |= M_INT3;

	// Enable EPWM INTn in the PIE: Group 3 interrupt 1-6
	   PieCtrlRegs.PIEIER3.bit.INTx1 = 1;

	// Enable global Interrupts and higher priority real-time debug events:
	   EINT;   // Enable Global interrupt INTM
	   ERTM;   // Enable Global realtime interrupt DBGM

	// Step 5. Loop and execute functions forever.
	   for(;;)
	   {

	   }
}

If you need any further information please advise.

Thanks,

-Alex