Question
Problems with floating point calculations in main loop as well as in ISR
Posted on September 14, 2015 at 15:06
Hello everybody,
in my Cosmic C program for a STM8S003 I have a problem: The result of some floating point calculations are sporadically corrupted. The usage of variables can not be the cause for that because the used ones are are interrupt-save. Also RAM space for variables and stack is not getting narrow. There is much space left. In my normal main loop program there are some floating point calculations (multiplications, additions, divisions). In an interrupt service routine there are also floating point multiplications and additions used. When I disable interrupts while the main loop calculations are done the problem is gone! But I don't really want to do that. I want to understand the cause. In the disassembly I noticed that in both cases (main and ISR) the folowing assembly ''functions'' are used: CALL c_rtol CALL c_ltor CALL c_fmul Could it be possible that these functions are not reentrant and that data is corrupted when the same ''function'' is called from main and from the ISR? When this is the case, is this normal or could it be considered as a bug? Thank you.