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.

Compiler/TMS320F28069: DELAY_US() using XAR4 register not ACC

Part Number: TMS320F28069

Tool/software: TI C/C++ Compiler

Hello

We are using the DELAY_US() macro in our projects

The F2806x_usDelay.asm comments says that the call from c code to assembly should be

        MOV   AL,#LowLoopCount
        MOV   AH,#HighLoopCount
        LCR   _Delay

  Or as follows (if count is less then 16-bits):

        MOV   ACC,#LoopCount
        LCR   _Delay

My call from c code is as follows:

DELAY_US(1000L);

which generates the following assembly code

MOVL         XAR4, #0x3f6c8e
LCR          $../lib/2806x/F2806x_usDelay.asm:68:81$

It looks to me that the compiler uses XAR4 register, not the ACC as stated in F2806x_usDelay.asm and the delay doesn't wait the stated micro seconds.

How can I force the DELAY_US macro to load the ACC register

Compiler is 15.12.1 LTS

Thank you in advance for your advice

  • Hello,

    I can't reproduce this. With the same usDelay function and the same compiler version, my generated assembly always does "MOVL ACC, XAR4" between the "MOVL XAR4, #whatever" and the "LCR #_DSP28x_usDelay". Where are you looking at this assembly code? In the disassembly window or did you turn on the option for the compiler to keep the generated asm?

    At what speed is your system clock running? What value of CPU_RATE are you using in F2806x_Examples.h?

    Whitney
  • Hello Whitney

    Thank you for your quick reply.  My CPU_RATE is defined as 11.111L. The macro is expanded as

    DSP28x_usDelay(((((long double) ADC_usDELAY * 1000.0L) / (long double)11.111L) - 9.0L) / 5.0L)

    I'm viewing the assembly code in Disassebly window, .asm file shows the same code (except for the debug symbols linked to my .c file)

    I tried with the Example_2806xAdcSoc code and this produces the correct result so there must be some faulty setting in my project.

    My code was build with rts2800_ml lib so I tried to move to rts2800_fpu32 and compiler instruction --float_support=fpu32. Unfortunately this didn't change my result in the end.

    BR  Magnus

  • Do you have any optimization turned on?

    When you step into the DSP28x_usDelay function and look at the ACC in the registers window, does it contain the wrong value?

    Whitney

  • Dear Whitney

    Yes optimization is on -O2.  I managed to solve the problem. Turns out that there was an redeclaration of  DSP28_usDelay function as

    extern void DSP28x_usDelay(long double A);

    And by investigation of the example code I saw that the function declaration was supposed to be

    extern void DSP28x_usDelay(Uint32 Count);

    Changing to this declaration I get the missing MOV ACC instruction before the call to DSP_usDelay()

    Thank you for the much appreciated support

    Magnus