We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I get strange behaviour with integer conversion; in the following example T4Frozen never reaches the value 790 because it turn back to 700 when it step over 767. This happen both on the target and on Dscope.
T4Frozen=700; while(TRUE){ PeriodoEncoder=(float)T4Frozen; PeriodoEncoder/=2.5; T4Frozen++; if(T4Frozen>790){ Dummy=700; } }
I would strongly recommend not using floats inside an ISR at all. Aside from the fact that any operation on a float is fairly time consuming it involves calls to library functions which I would guess are not reentrant. If this is the case your ISR could corrupt any floating point calculations anywhere in your program, not just ones involving the FP variable modified in the ISR. Whenever you need to share any multibyte variable between an ISR and the rest of your program you must declare it as volatile and also disable interrupts while accessing it outwith the ISR. I like to use a function similar to this: long ReadSharedLong(long *shared) { long temp; EA=0; temp=*shared; EA=1; return(temp); } Stefan
Or try:
#pragma DISABLE long ReadSharedLong(long *shared) { return(*shared); }
We use floats into main and 2 ISRs, and so I'm really worried about: Aside from the fact that any operation on a float ... involves calls to library functions which I would guess are not reentrant This is much more difficult to manage than data consistence. We can't disable interrupts (or at least one of them) so we are trying to use integers where it is possible, and could be hard work. Any other way could be dangerous. Thanks a lot
Alfredo, Please note that I do not know whether the FP library functions are reentrant or not. You need to check the manuals or check with Keil if the info isn't there. Stefan
We have posted a technical request directly to keil because the problem is still active and we are thinking that it is binded in some way to floating point library. Strained all the gnats but still swallowing the camel! Thanks again