Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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: How to define a variable in the assembly file can also be called in the C file?

Tool/software: Code Composer Studio

Hi,

I want to define a variable in the DPL-ISR.asm file, use ".if" to determine whether this variable can perform PI control, and can also call this variable in the C file.

I tried to use the following format to define but the error.

.bss _CurrnLoop, 1

 .global _CurrnLoop
               …
 .if (#_ CurrnLoop == 1)
               …
 .endif

How do I change it, is there any relevant instruction manual. thank you very much!

  • Based on your earlier posts, I presume you use a C28x device.

    To understand how to write C code that accesses a variable defined in assembly, please search the C28x compiler manual for the sub-chapter titled Interfacing C and C++ With Assembly Language.  

    Note the .if directive ...

    user3636465 said:
     .if (#_ CurrnLoop == 1)

    is similar to the #if preprocessor directive in C.  That is, it has an effect at build time, but not run time.  For further information, please search the C28x assembly tools manual for the chapter titled Assembler Directives.  

    Thanks and regards,

    -George

  • Hi ,

    hank you for your reply. But there are still errors. 

    My code and error report are shown below:

    1.Variable definitions

    2.Error in calling variable in assembly file

    3.error report

    I have been using C language and I am not very familiar with assembly. I hope to get your help. Thank you!

  • That is not how the .if directive is to be used.  It is for making a decision at build time, not run time.  

    For decisions made at run time, you need to use C28x assembly code instructions.  Those are documented in C28x assembly manual.  

    I recommend you write some C code that does a similar operation to what you want to implement in assembly.  Build the code with the option --src_interlist.  This option causes the compiler to keep the automatically generated assembly code file, and to add comments to it which make it easier to understand.  This will give you an idea of what assembly directives and instructions you might use.

    Thanks and regards,

    -George

  • thank you very much! I found the information I need-TMS320C28x Assembly Language Toolsv20.2.0.LTS.