I've been using sqrt for a while without any issue.
Added a loop to run this function many times to average many ADC samples.
It runs fine then on the 5th time locks up on the second STA here:
STA Kexp:1
PULA
ADC #(D_EXPHI)
STA Kexp:0
; // { exp done }
My code is:
void ADC(void) { float Fresult; float PFResult; float Result_a; float Result_b; float temp; float Result_c; /* take 4 ADC readings: VOLT, CURR, FREQ and PF */ Fresult = (float)FREQ; PFResult = (float)PF; Result_a = (VOLT*VOLT)/(CURR*CURR); temp = sqrt(Fresult); Result_b = PFResult/(temp*Fresult); Result_c = Result_a*Result_b*4096; adcval = (int)Result_c; return;}//ADC
Hangs up on the "temp" variable. Only on the 5th time through this code.
The only difference is a counter goes from 4 to 5 for this cycle, but I don't see how that'd make a difference.
What's happening here?
Many thanks!