11 Jun 2012 20:48
libm with pic16 port, problem with reetrancy?
Hello,
I discover some strange behaviour of sqrtf() function when usart
interrupts are enabled.
My sdcclibs are compiled with --stack-auto option, libm too.
My program is simple and just do a sqrt calculations in endless loop
(my code compiled is with --stack-auto):
float val;
unsigned int x;
while(1){
val=sqrtf(20000);
x=(unsigned int) val;
if(x!=141) printf("x=%u val=%.4f",x,val);
}
When usart receive some data (usart interrupt routine does some
integer calculations, only integer, not float) sometimes I get
randomly wrong values from sqrtf():
x=0 val=0.0000
x=19 val=19.0000
x=1 val=1.0000
I suspect some reentrancy problems, becouse when usart doesn't receive
any chars, sqrtf always return 141.4214
As I metioned above libsdcc and lib are compiled with --stack-auto, so
all helper (int/float) functions should be reentrant...
regards,
ml
(Continue reading)
RSS Feed