I am having trouble getting a macro to work in my application and I am wondering if anyone knows a way to fix this with compiler settings. This is part of trunk code that spans over several compilers so chaning the code would make things difficult.
Here is the macro:
#define TimeOver(soll,ist) ((UINT16) ((ist) - (soll)) < 0x8000)
And here is one instance of where it is used:
if(TimeOver (FUTURE_TIME, CURRENT_Timer))
{
...
}
Basically, it is a timeout mechanism. The problem is the condition always comes out true even when it is not. I know this macro works on at least 5 or 6 other compilers, but I can't get it to work correctly in this case.
For debugging purposes, I added in a temp variable so I could see what was going on with the TimeOver macro and the system started working.
temp = TimeOver (FUTURE_TIME, CURRENT_Timer);
if(temp)
{
...
}
Does anyone have an idea of why this could be going on? Thanks in advance.
Solved! Go to Solution.
BOOL TimeOver (uint16_t soll, uint16_t ist) { uint16_t result = ist - soll; return result < 0x8000U; }
BOOL TimeOver (uint16_t soll, uint16_t ist) { uint16_t result = ist - soll; return result < 0x8000U; }