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.

__delay_cycles is undefined

Part Number: MSP430F5529
Other Parts Discussed in Thread: C2000WARE

Tool/software: TI C/C++ Compiler

Hello everyone,

I am trying to use the __delay_cycles compiler intrinsic. But it won't compiile.

#20 identifier "__delay_cycles" is undefined    EncoderTW29.cpp    /4AchsModul_CPU2/Source/Encoder    line 777    C/C++ Problem




In the same project I am using intrinsics like __add or __sub. Those are working.

I am using the TI v20.2.2.LTS compiler.

If __delay_cycles isn't supported anymore, is there a way to invoke a nop multiple times with one __asm() instruction?

Thanks and regards,

Marcel Kummer.

  • I am unable to reproduce this behavior.  For the source file EncoderTW29.cpp, please follow the directions in the article How to Submit a Compiler Test Case.

    Thanks and regards,

    -George

  • EncoderTW29.pp.txt

    "C:/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --include_path="C:/ti/ccs1011/ccs/tools/compiler/ti-cgt-c2000_20.2.2.LTS/include" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/TIdriverlib" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/Framework" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/cpu02/TI Dateien/headers/include" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/cpu02/TI Dateien/common/include" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/Params" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/cpu02/Source/Regler" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/ControlComponents" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/Atomic" --include_path="C:/Users/marcel.kummer/Documents/Projects/Produktplatform_2020_Software/Taskverteilung auf allen Cores/common/Source/Pinmuxing" --define=CPU2 --define=LOGGING --define=LOAD_MONITOR --define=TASK_GUARD -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --display_error_number --abi=coffabi --obj_directory="Source/Encoder"  "../Source/Encoder/EncoderTW29.cpp"

    ti-cgt-c2000_20.2.2.LTS


    I hope this is what you meant.

  • Hi,

    Assigning the thread to expert from MSP team.

  • Hi,

    If you have installed C2000ware SDK, please refer to following file for delay function.

    C:/ti/c2000/C2000Ware_3_03_00_00/device_support/f28004x/common/source/f28004x_usdelay.asm

  • Hello Santosh Jha

    so basically you say, that the compiler intrinsic __delay_cycles is not supported anymore?

    If I understand it correctly I could also just do several nop instructions to get the delay.
    Isn't that more accurate than the approach in usdelay.asm ? Since with nops I could add delay cycles in increments of 1 instead of 5?

    I got that from the f28004x_sysctrl.c:
    // Macro used for adding delay between 2 consecutive writes to CLKSRCCTL1
    // register.
    // Delay = 300 NOPs
    //
    #define SYSCTRL_CLKSRCCTL1_DELAY  asm(" RPT #250 || NOP \n RPT #50 || NOP")

    So in my case i want to delay 40 cycles, so I would do
    asm(" RPT #40 || NOP");

    Regards,

    Marcel Kummer.

  • Marcel,

    Regarding intrinsic, compiler expert is looking into it. Meanwhile you can use the delay macro.

  • Marcel Kummer said:
    so basically you say, that the compiler intrinsic __delay_cycles is not supported anymore?

    Other compilers from TI, such as the one for MSP430, support an intrinsic named __delay_cycles. But the C28x compiler has never supported an intrinsic named __delay_cycles.

    Thanks and regards,

    -George

  • Oh I see,

    I think I found it in an arm compiler documentation. Since I also found the intrinsic used inside an example in the C28x-Compiler docu I thought it is usable there too.

    If you are using non-volatile RAM, you can define a persistent variable with an initial value of zero loaded intoRAM. The program can increment that variable over time as a counter, and that count will not disappear if thedevice loses power and restarts, because the memory is non-volatile and the boot routines do not initialize itback to zero. For example:
    #pragma PERSISTENT(x)
    #pragma location = 0xC200 // memory address in RAM
    int x = 0;
    void main() {
        run_init();
        while (1) {
            run_actions(x);
            __delay_cycles(1000000);
            x++;
        }
    }



    Regarding my other question:
    Do I understand correctly, that asm(" RPT #40 || NOP"); will delay 40 cpu cycles?

    Regards,

    Marcel Kummer.

  • Marcel,

    Marcel Kummer said:
    Do I understand correctly, that asm(" RPT #40 || NOP"); will delay 40 cpu cycles?

    This will be 41 cpu cycle.

    Please refer to section 2.5.3 in following document on C28x instruction set.

    www.ti.com/.../spru430f.pdf