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.

TMS320F280039C: apis from a large header file in the c2000 library are causing some problems

Part Number: TMS320F280039C

hello 
i used the PWM header file in my project included the header file and called some apis from there in the source file, the problem is the code is not doing what it is supposed to do in that source file but it is working in another source file ?? here i will explain more :

the code is compiled and deployed to the launchpad without any problems but when i step through the code the apis doesn't work at all it is not effective inside that source file but effective in another source file, i tried to set global flags inside that function in which the apis doesn't work and the flags were set without any problem, then used those flags in a if statement inside the task scheduler if set it will call the apis that were not working in the other source file and it worked fine. i don't understand the problem why the same apis work well some where and doesn't work somewhere else. what i mean by doesn't work is that the debugger steps and execute the code but no result come from it "the volt changes", i used only the two apis 

EPWM_setActionQualifierContSWForceAction
EPWM_setCounterCompareValue


i think the problem has something to do with the EPWM header file itself that file is big and caused a stack overflow problem when i run that code i had to increase the stack so that the code works, also i got the message of editor scalability 

and why do you think the stack oveflow happens ? 


  • Hi Mahmoud,

    Stack overflow can occur when too many variables are referenced but not dereferenced, so their presence on the stack stays throughout program execution. This header file is big probably has a lot of defines and global variables that are weighing it down. A way to avoid this would be to make sure you do not have any double references to variables and to possibly split the header file variables/functions not used. 

    Best,

    Uttam

  • thank you for your response
    i don't know how to split a c2000 library header file "EPWM.h" can you show me how ? 
    also could you please give me an example about double reference because all i did was just to use the api ? 
    regarding the main issue do you have any comment about it why the code dosen't run in a one file and works in the other ?  or maybe you don't quite understand what i mean... (sorry if my question is not clear) 

  • Hello Mahmoud,

    I want to try to restate the problem to make sure I'm understanding what you're saying; when you try to run the APIs, you're testing to see if it works by setting global flags inside of a function that uses the API (where it's not working as expected), and the global flags do get set. Then somewhere else you have a conditional statement that checks if those flags aren't set and calls the APIs somewhere else (can you explain where this other 'source file' is located and how it's linked with your project?), and there the API does work as expected.

    what i mean by doesn't work is that the debugger steps and execute the code but no result come from it "the volt changes"

    I don't understand the above statement, what do you mean by "no result comes from it 'the voltage changes'"?

    i think the problem has something to do with the EPWM header file itself that file is big and caused a stack overflow problem when i run that code i had to increase the stack so that the code works, also i got the message of editor scalability 

    and why do you think the stack oveflow happens ? 

    Regarding stack overflow, this is not because of memory used by the driverlib files, stack overflow is caused because there is more data pushed to the stack than the stack has room for. Typically this happens because of recursive functions (intentionally or unintentionally), and is usually something caused by the program, not something that is allocated to the device initially. When the error occurs, you can look at the stack pointer in the Register window in the debug session and find the memory it's locating to (also the return program counter register is useful to see what function the code was going to return to). You can locate this address in the Memory Browser window. If you're concerned that there isn't enough memory because of how much memory is required for the program code, you can check the Memory Allocation window after building your project (View > Memory Allocation).

    I'm not sure about the editor scalability issue, can you send me a screenshot of the message from CCS?

    Best regards,

    Omer Amir

  • Hello Omer 
    i mean by no result came from it is that : the Register values don't change and the pin output voltage is not zero as expected when using the api 
    EPWM_setActionQualifierContSWForceAction(Test_PWM_BASE, EPWM_AQ_OUTPUT_B , EPWM_AQ_SW_OUTPUT_LOW);.......i am sure that the problem is not about wrong inputs to the api as it is working in another source file of the same project, 
    although when i make step in both head to the EPWM.h file and goes to the api one works and update the register the other doesn't ! 

    the source file where the api works is the task scheduler source file where we have an api for the RTOS 1 sec task 100ms second task and so on 
    the file where the api doesn't work is a regular component file, note that the EPWM header file is included in that file i tried to include it in another header file and include that header file in where i call the api hoping it will make a difference but it didn't. 

    for the scalability 

    i hope that i made my question clear, please ask me to elaborate more if you still can't understand me, i may record a short video for that 

  • Hello Mahmoud,

    i am sure that the problem is not about wrong inputs to the api as it is working in another source file of the same project, 

    What you say here indicates that this is more than likely a problem with the inputs, not the other way around. Given that both function calls go to the same API, and one works while the other doesn't, this is most likely a problem with how the regular component file is calling this function. You will need to set a breakpoint within the API and step through each line of code to verify the register values are changing and the input parameters are what you're expecting (you should then locate at what point it does something incorrectly, this should be narrowed down to maybe a handful of lines rather than the entire API).

    For the scalability issue, this is disrelated from the current problem you're seeing; essentially the file is very big and your settings for CCS are making this warning show up (you can change the scalability to ignore performance issues of the CCS application to be able to view larger files).

    Best regards,

    Omer Amir

  • thank you so much, you know i never thought it would be the inputs as i just copied the whole line of the api with its inputs, but turned out that the first argument which is the base address is having a grabage value i don't know why it has a the right value in a file and undefined in the other file even though other macros are working fine. 
    problem is solved