Memory operation "skipping" steps in DEBUG mode of Keil UV5

I'm running into some rather strange things lately.

In debug mode, let's say I have two lines:

    a[0] = 0;

    a[1] = 1;

If I place a breakpoint at the 2nd line, and the original value of a[0] is 0xFF, then its value will stay at 0xFF, till the function exists. Yes, you heard it right, as if the line:

    a[0] = 0;

hasn't been executed at all!

However, if I place the breakpoint at that line or before, a[0] will correctly be changed to 0.

And it's not just that, let's say I have another section of code:

 

    for(int i = 0;i<4;i++)

    {

         a[i] = p_cache++;

    }

If I place the breakpoint after this code, array a will not be updated! If I place the breakpoint before the code, the value will be successfully updated into array a.

Note that it's not a lag/delay issue. This phenomenon persists throughout the life cycle of the entire function unless I specifically place the breakpoint before the problematic code.And the execution of the program is affected as well, so I'm not seeing "ghost values". The error is very real.

This is highly unusual, can anyone shed some light on what's going on? Maybe I didn't configure my development environment right?

Thanks in advance.

Related