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/LAUNCHXL-F28027: Code Composer Studio Problem. HELP PLEASE.

Part Number: LAUNCHXL-F28027
Other Parts Discussed in Thread: TMS320F28027

Tool/software: Code Composer Studio

Good Morning people, Yesterday i posted a thread that was asking for some problem with code unstability in the Code Composer Studio Forum. In that post i explain that im developing a code with ePWM interrupts, ADC, etc etc. and i was doing some printings by console. then i said that the code becomes unstable when i delete or add a different line to te program, even if the line does not interfer with the functionality of the program. 

I was experimented problems like the program dont stop interrupts (in a part of the program it must have stop ePWM int to do some mathematical operations that require a series of data stored in memory, just 100 integer data). Or other of the problem that i saw when i make a minimal change in the source code (f ex. comment a simple instruction that wotn interfer with the functionality) was that the CCS is not enabling the interrupts of ePWM to continue with the program. 

Then i noticed that if i run the program step by step it read the instructions, but when i get a critical point (f ex. Disabling interrupts) the programs just ignore my step over and it plays again freeruning, it depends on the mood of CCS =/. and besides it ignores my step over its just like the instruction wasnt there and it keeps with the interruptions.

i also noticed that my program its not running as i want because the CCS is "jumping" the critical instructions (f ex. enabling or disabling interrupts), but i repeat, this just happen if i make insignificant changes on my functional but so unstable source code. I dont found any logic on this behavior with and i dont know how to solve it. Is a kind of "optimization" implemented by the CCS the "jumping instructions" and no reading instructions? How can i solve this problem? HELP PLEASE. at this point i dont know what to do.

For last, it supose that i have to store a data in a .txt file, it works perfectly and my unstable but functional code stores the data, but it does that only once time, if i want to overwrite my data is like it is jumping the instructions again, because it dont store any data, just left the .txt file empty with none data.

I would rlly apreciate if someone knows what is happening and help me to solve it.

Eliomar Conde. Regards from venezuela.

  • Hi Eliomar,

    It seems that the issue you're seeing regarding skipping steps may have to do with the optimization used in the project. This affects the way the code is compiled and executed. What optimization level are you using with your project? Perhaps you can attach a snippet of code where you have observed the behaviour.

    Regards,

    Ozino

  • Hi Ozino, about the level optimization i really dont know, i didnt not touched those settings and i dont know how to see or change those settings. could you tell me?

    And yes i can attach a section of the code where i observed this behavior or maybe the complete source code if you want. i just need help to solve my inconvenient. for the moment i will attach only a fragment.

    The ePWM INTERRUPT SERVICE ROUTINE.

    __interrupt void epwm1_timer_isr(void)
    {

    var = 2500 + 2400*sin(2*PI*n/100);

    while(ADC_getIntStatus(myAdc, ADC_IntNumber_1) == 0) {
    //printf("esperando... \n");
    }

    ADC_clearIntFlag(myAdc, ADC_IntNumber_1);
    Buffer[n] = ADC_readResult(myAdc, ADC_ResultNumber_1);
    //Corriente[n] = ADC_readResult(myAdc, ADC_ResultNumber_2);

    n = n + 1;

    if (n==100){
    n = 0;
    prom = 1;
    }

    S = GPIO_getData(myGpio, GPIO_Number_12);

    PWM_setCmpA(myPwm1, var); //Fijamos CMPA al valor de la senoidal

    // Clear INT flag for this timer
    PWM_clearIntFlag(myPwm1);

    // Acknowledge this interrupt to receive more interrupts from group 3
    PIE_clearInt(myPie, PIE_GroupNumber_3);
    }

    I see, sometimes, if i make a little change in this code. stupid changes.
    like if i change the "Buffer[n] = ADC_readResult(myAdc, ADC_ResultNumber_1);" for exactly
    "Buffer[n] = ADC_readResult(myAdc, ADC_ResultNumber_1) + 70;" (The same number +70)
    the program apparenlty skips the line "S = GPIO_getData(myGpio, GPIO_Number_12);"
    Because this line must stop the ePWM interrupts and run the next SECTION OF CODE stored in MAIN():

    if( S == 1){

    //PIE_disable(myPie);
    //PIE_disableAllInts(myPie);
    CPU_disableGlobalInts(myCpu);
    CPU_clearIntFlags(myCpu);

    PWM_setCmpA(myPwm1, 4999);
    PWM_setDeadBandOutputMode(myPwm1,PWM_DeadBandOutputMode_Bypass);

    GPIO_toggle(myGpio, GPIO_Number_3);

    V = 0;

    DELAY_US(1000000);

    Archivo = fopen("Voltaje.txt","w+");

    for(i=0;i<100;i++){
    V = V + Buffer[i];
    fprintf(Archivo,"Buffer[%d] = %d \n", i, Buffer[i]);
    //fprintf(Archivo,"Corriente[%d] = %d \n", i, Corriente[i]);

    }

    fclose(Archivo);

    VDC = V*(1/100.0);

    VDC = (VDC*(0.023376598399)) + 2.5;

    S = 0;

    while(S == 0) {
    S = GPIO_getData(myGpio, GPIO_Number_12);
    }

    printf("%f Voltios DC \n", VDC);

    GPIO_toggle(myGpio, GPIO_Number_3);

    DELAY_US(1000000);
    S = 0;

    while(S == 0) {
    S = GPIO_getData(myGpio, GPIO_Number_12);

    }

    DELAY_US(1000000);
    GPIO_toggle(myGpio, GPIO_Number_3);
    PWM_setDeadBandOutputMode(myPwm1,PWM_DeadBandOutputMode_EPWMxA_Rising_EPWMxB_Falling);

    S = 0;

    CPU_enableGlobalInts(myCpu);
    CPU_enableDebugInt(myCpu);

    }

    }

    If you see, this section of code, disables global interrupts and i need to change the state of gpio12 three times to enable the interrupts again.

    Well the thing is that sometimes depends on what i change on the program. like comment the line of printing voltage (that does not have any significant effect on the program function).
    It starts a wrong behavior, like the interrupts dont stop, even if the gpio12 button is pressed. Or another thing that happends is that the program disables the interrupts effectively but then does not enable the interrupts and the program is dead (because the life of the process is the interrupt routine). Or another thing that also happends is that the .txt file just save data the first time, the next times it just save and empty file.
    If you want i can send you the complete source code, so you can test it, but a the moment the left fragments are just peripheral configurations, PWM, ADC, GPIO, PIE, etc.

    I hope you could help me with this Ozino. Thanks in advance.
    Regards. Eliomar
  • Eliomar,

    The optimization settings can be viewed by right-clicking on the project and selecting properties. In the pop-up window, navigate to Build -> C2000 Compiler -> Optimization. This is where the optimization information is located.

    Regards,
    Ozino
  • ahh ok. it is in level "0". does it means that the compiler wont optimize the code? or i should set "off" the code optimization?
    the reason of the problem could be other thing besides the optimization?
  • It is not the optimization level, i changed the setting to "off" and my problem its still happening. A question, when i run my code step by step.
    Step into means that i go inside the instruction no?
    Step over means that it pass the instruction? it doesnt makes the operations of the instruction or it just doesnt show inside the instruction?
  • Hi Eliomar,
    try to run your : interrupt void epwm1_timer_isr(void) in ram it may solve your problem
    Best regards
    hamid
  • Eliomar,

    Stepping into, will go inside the instruction and wait for the next action. Stepping over a function will not go into the instruction, but will execute it in one entire step.

    Does your project include any libraries(.lib)? If so, some of what you may be seeing may be due to functions in the library that are being called during execution. If you're stepping thorugh the C code you will experience what you have described. However, if you step through the disassembly you should still be able to step through each instruction.

    Regards,

    Ozino

  • ahhh ok. but in the critical sections of the source code (the disable and enable intrerrupts instructions) it sometimes disable or enable the interrupts. i mean not all the time the CCS disable or enable the interrupts.
    My program include the stdio, math, and the peripheral libraries of the tms320f28027.
    so, if im stepping the instructions one by one, it is ok if in sometime the CCS plays the code on freeruning?
  • Eliomar,

    I believe that there's nothing wrong with CCS. You will need to make sure to check on the priority of your interrupts. You also need to make sure that you have enough bandwidth for the other interrupts that you are trying to call. You will have to adjust the priorities of the interrupts to suit the desired functionality.

    Additionally, when you step into a single line of code, CCS takes the lowel level assembly equivalent for the C code and executes that until the next line of C code. Take note that the C code does not have to be a function call it is for any line of C code. This also means that you can also single step through equivalent assembly code.

    If you also jump to specific lines in your code. CCS will not always execute the entire code between the two lines.

    Hope this helps,
    Ozino