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/TMS320F28335: CCS debugs my program correctly but device does not run it properly

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi,

I have tried to run the example code "adc_seqmode_test" and "add_seq_ovd_test". I have also tried to run the following simple code on my device:

#include "DSP28x_Project.h"
void main(void)
{
Uint32 delay;
InitSysCtrl();
//
// Configure GPIO43 as a GPIO output pin
//
EALLOW;
GpioCtrlRegs.GPBMUX1.bit.GPIO37 = 0;
GpioCtrlRegs.GPBDIR.bit.GPIO37 = 1;
EDIS;
while(1)
{
//
// Toggle LED
//
GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
//
// Delay for a bit
//
for(delay = 0; delay < 10; delay++) //20000 is roughly 2 ms delay
{
}
//
// Toggle LED
//
GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
//
// Delay for a bit
//
for(delay = 0; delay < 10; delay++)
{
}
}
}

My device came with a pre-installed program that toggles the GPIOs at approximately 1 Hz frequency; this program is executed by default when I power-up my device.

I have configured the debugger to halt at main() so that I can check the code line-by-line. The trouble is, when I check it this way (using step over(F6), step into (F5) etc), the codes work fine. I have attached an oscilloscope to the GPIO pins to monitor the desired output and it is ok as well. But, instead of executing the code line-by-line, when I press the 'resume' button (the one with the green arrow pointing right), my code does not run. Instead the device reverts to the pre-installed program and starts toggling the GPIO pins at 1 Hz. This happens for every code that I try to run in the debugger, even the simple code shown above.

Please help.

  • Hi,

    Muhammad Subhani said:
    when I press the 'resume' button (the one with the green arrow pointing right), my code does not run. Instead the device reverts to the pre-installed program and starts toggling the GPIO pins at 1 Hz.

    This indicates that either your code or an external factor is causing the processor to reset itself during the normal execution. 

    In these cases, either an invalid instruction or device configuration can cause the processor to reset. Another common scenario is a watchdog timer that is not properly serviced or disabled, which resets the device after some time. 

    I will notify the C2000 device experts as they will be able to help you further in details related to the device itself. 

    Hope this helps,

    Rafael

  • Ok.

    Is it possible that I am making some mistake in ccs build configuration?

  • Hi,

    Could you please let me know if you are running the code through RAM or Flash?

    Is your project configuration a RAM build configuration or Flash build configuration?

    Can you try to halt the program in the middle of execution and check if program is stuck in your code?

    Thanks, Katta

  • I think I am running my code through RAM, and my build configuration is for RAM too (but I may have made some mistake in the configuration)

    Like I already said, If I debug the code line-by-line, it works correctly from start till end (I even monitor the output pin: GPIO37 using an oscilloscope). The problem only occurs when during debug, I press the 'resume' button. The program should keep running by itself, but instead it reverts to the factory installed program.

    I cannot halt my code during execution since it never executes in the free-run mode.

    Below is the sample code which I am trying to execute. (I'm a newbie so please be gentle :) )

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    // ADC start parameters
    #if (CPU_FRQ_150MHZ)     // Default - 150 MHz SYSCLKOUT
      #define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3)   = 25.0 MHz
    #endif
    #if (CPU_FRQ_100MHZ)
      #define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2)   = 25.0 MHz
    #endif
    #define ADC_CKPS   0x1   // ADC module clock = HSPCLK/2*ADC_CKPS   = 25.0MHz/(1*2) = 12.5MHz
    #define ADC_SHCLK  0xf   // S/H width in ADC module periods                        = 16 ADC clocks
    #define AVG        1000  // Average sample limit
    #define ZOFFSET    0x00  // Average Zero offset
    #define BUF_SIZE   1024  // Sample buffer size
    
    // Global variable for this example
    Uint16 SampleTable[BUF_SIZE];
    
    main()
    {
       Uint16 i;
       Uint16 a;
       a=0;
    
       // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the DSP2833x_SysCtrl.c file.
       InitSysCtrl();
       a=a+1;
    
    
       //
       // Configure GPIO43 as a GPIO output pin
       //
       EALLOW;
       GpioCtrlRegs.GPBMUX1.bit.GPIO37 = 0;
       GpioCtrlRegs.GPBDIR.bit.GPIO37 = 1;
       EDIS;
    
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // Specific clock setting for this example:
       EALLOW;
       SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK
       EDIS;
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // Step 2. Initialize GPIO:
    // This example function is found in the DSP2833x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example
    
    // 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();
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // Disable CPU interrupts and clear all CPU interrupt flags:
       IER = 0x0000;
       IFR = 0x0000;
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // 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();
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // Step 4. Initialize all the Device Peripherals:
    // This function is found in DSP2833x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
       InitAdc();  // For this example, init the ADC
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    // Specific ADC setup for this example:
       AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK;
       AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS;
       AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;        // 1  Cascaded mode
       AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0;
       AdcRegs.ADCTRL1.bit.CONT_RUN = 1;       // Setup continuous run
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
    
    // Step 5. User specific code, enable interrupts:
    
    // Clear SampleTable
       for (i=0; i<BUF_SIZE; i++)
       {
         SampleTable[i] = 0;
       }
       a=a+1;
       GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
    
       // Start SEQ1
       AdcRegs.ADCTRL2.all = 0x2000;
       a=a+1;
    
       // Take ADC data and log the in SampleTable array
       for(;;)
       {
         for (i=0; i<AVG; i++)
         {
            while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt
            AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
            SampleTable[i] =((AdcRegs.ADCRESULT0>>4) );
            GpioDataRegs.GPBTOGGLE.bit.GPIO37 = 1;
            a=a+1;
         }
       }
    }
    
    //===========================================================================
    // No more.
    //===========================================================================
    

  • I tried to debug the program again and this time I found something interesting. There are four functions in the code which came with the C2000 ware:

    InitPieCtrl();

    InitPieVectTable();

    InitAdc();

    I added a breakpoint before these three functions.

    When the program halted at either of these functions, I pressed F5 (step into) and then executed the code step by step. The device responded correctly. However if I pressed the 'resume' button instead of 'stepping into', three things happened:

    1. The device returned to execute the default (pre-installed) code (GPIO toggle at 1 Hz)
    2. The 'suspend" or 'pause' button became available
    3. The disassembly window appeared and the following message was displayed: 

    Break at address "0x33841f" with no debug information available, or outside of program code.

    When I pressed the 'suspend' button, the device stopped executing its default code.

    This happens at all three functions

    I hope someone can help

  • Sorry, I mean't three functions in my last message.

  • Hi,

    I am adding a few suggestions based on my understanding.

    When you jump to main you can see your code gets executed but when you run directly it won't enter your code. Looks like there is a code in the Flash. Can you try erasing complete flash ?

    Meanwhile i don't see if you have given enough time between each toggle. Could you please run \C2000Ware_X_XX_XX_XX\device_support\f2833x\examples\timed_led_blink to check if this example behaves in the same way?

    Thanks, Katta

  • If I run directly, it enters main(), however the problem is encountered when InitPieCtrl(), InitPieVectTable(), and InitAdc() are encountered.

    I ran the timed_led_blink code as well. once again the device reverted to default code somewhere during the timed_led code and the following message appeared:

    Break at address "0x338421" with no debug information available, or outside of program code

    For my previous codes, this address used to be: "0x33841f"

    I read somewhere that I may need to see the memory map to sort out this problem. But I cannot find the memory map.

    Regards,

  • Just found out, both these addresses belong to sector A of the 256K Flash. But now I cannot understand why the code jumps to these addresses?

    Are these addresses reserved for some ISR?

    Further, is there a guide available to erase the flash using CCS?

    Will the pre-installed code still run on power-up after I erase the flash?

    Regards,

  • I have even tried to use the example codes provided in the ti install directory, but the result is the same

  • Dear all,

    I got to the root of the problem. The device-board was not receiving enough current. So although it powered up correctly and the JTAG test passed, it could not operate in free-run mode. I simply attached a power adapter with higher current rating and now everything works ok.

    Thanks anyway.

    Regards