- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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