Hi all,
sorry for late answer, I did lot of try and I came to the the conclusion that it's an interrupt-related stuff.
xiangjun.rong it is not a debugger issue, cause the problem happens even without it connected.
Look at this piece of code just to show you the problem (located in main.c file, in main() function):
prova = 1830.0;
value = FRAC16(prova / 4095.0);
valueCompare = FRAC16(195.0 / 434.0);
while (value < valueCompare) {
WDog1_Clear();
value = FRAC16(prova / 4095.0);
}
As you see, 'value' variable has always the same value (both variable are Frac16).
So, this should be an infinite loop, 'value' (14643) is always < than 'valueCompare' (14722).
In fact, debugging, it enters in the while cycle, but if I put a breakpoint after the while cycle, after random (?) time the breakpoint fires! This because 'value' become 32767 (looking with debugger)!
If I disable interrupt before line 7 and re-enable after it, all is ok.
Note that if I put fixed values at line 7 (value = FRAC16(1830.0 / 4095.0), it's again all fine (infinite loop).
What should I do? I think it's impossible nobody had this problem before...
Please help me I can't enable-disable interrupt every time I need that macro.
Thanks
Sandro