emulator will not set a break point on a line of code, why?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HeGi_2497906
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

OK, really odd behavior, I have some code that we are using to set and clear bits in a data register in a buffer.  The code looks fine, but is not working, and when I go to debug it, the emulator will not allow me to place a breakpoint on the instructions, and places it at the end of the code, any idea why this is happening?  Started with a pointer to the register, thought it might be getting crush during an INTERRUPT, so I tried to make it a volatile, but you cannot have a pointer to a volatile in this environment.  When I try to set a breakpoint anywhere in the function it places it at the return brace?

I am totally stuck.

Here is the declarations. call and function.

void setBit(uint8 bit, uint8 byte, uint8 on);

volatile extern uint8 BLE_READINGS[READINGS_DATA_LEN];

setBit(STATUS_VOR, BLE_READINGS[READINGS_STATUS], TRUE);

// setBit(STATUS_CMD, READINGS[DB_STATUS], TRUE);

void setBit(uint8 bit, uint8 byte, uint8 on)

{

    if (on) {

        bit = 1 << bit;

        byte = byte | bit;

    } else {

        bit = 1 << bit;

        bit = bit ^ 0xff;

        byte = byte & bit;

    }

    return;

}

0 Likes
1 Solution

When you modularized your code (different files) you can set the optimization levelfor each file individually.

When you creaate a small project that isolates your error I could try to debug it and solve that problem.

Optimize out: The line

    bit = 1 << bit;

is in both if-branches and will be put before the if.

Bob

View solution in original post

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I would suggest to set the optimization to "none". Might help a bit. Optimized-out code lines cannot take breakpoints.

Your "error" might be that you have no return value and the parameter "byte" needs to be passed as an address (* uint8) to return a value to the calling program.

Bob

Hi Bob and thanks for the reply, we are at 98% code in this design, and so I cannot do that as it make the code too big for the memory.  Why would it optimize out the code?  I did try to use a pointer, and it failed as well, also if you use a pointer you cannot have the VAR be a volatile?

Herb

0 Likes

When you modularized your code (different files) you can set the optimization levelfor each file individually.

When you creaate a small project that isolates your error I could try to debug it and solve that problem.

Optimize out: The line

    bit = 1 << bit;

is in both if-branches and will be put before the if.

Bob

0 Likes