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.

code not include when compiling

Other Parts Discussed in Thread: TEST2

Hi

I have a simple for loop delay in my code, a function in main.c , when I build the project I don't get any errors, but when I debug code the code is not excuted. The debugger just jumps over that function call, althhough is use the "step into" button.

When I load the program into my micro and disconnect the debugger I can see that part of the code is definiantly not include in the code, because there is no delay.

What am I doing wrong? Please help.

Matt

 

 

  • Sounds to me like the compiler is optimizing that for loop out.  What does it look like?  Perhaps if you post it we can determine what the compiler is doing with this code.

    Just to verify if what I thought is correct, have you looked at the assembly code that is generated?  You may need to enable a Project Properties option to retain the assembly code in the build process, or just generate a listing file.  Another approach is to look at the code in the disassembly window and stop just before the for loop is to be implemented.  Then scan through and determine what might have happened.

  • Hi Brandon.

    Thank you for your reply. Here is my for loop funtion.

     

     

     

    void

     

     

     

    unsigned int x,y,z;

     

     

    if (T2 == 1)z = 3000;

     

     

    else z = 3003;

     

     

    for (x = 0; x < T2; x++);

    {

     

        for (y = 0; y < z; y++);

    }

    }

    Like I said it's a very simple piece of code. I Had a look in the assembler file, the for loop code is not in there.

    Where and what must I set so that the compiler will include my code as I have it.

    Regards

    TEST2(unsigned int T2)

    {

     

  • use: volatile unsigned int x,y,z;