AnsweredAssumed Answered

Strange float vs. int issue

Question asked by egawtry on Sep 9, 2015
Latest reply on Sep 21, 2015 by SachinV

I have a strange issue where the code doesn't make any sense.

 

             if( iBuffAudio >= nBuffAudio )
             {
                  double fInc     = (1000.0/32000.0);
                  double fTmp;
                  sample sTmp;
                  for( nBuffAudio = 0; nBuffAudio < (sizeof(BuffAudio)/sizeof(BuffAudio[0])); nBuffAudio++ )
                  {
                       //BuffAudio[nBuffAudio] = (int32_t)0;
                       if( s_fAccumulator >= 1.0 ) s_fAccumulator -= 1.0;

                       fTmp = sin(s_fAccumulator*M_2PI)*MAX_SAMPLE;
                       sTmp = float_to_fr16(fTmp);
                       BuffAudio[nBuffAudio] = sTmp;          // This crashes with "The call to adi_osal_Init made from the CRT startup code returned an error."
                       //BuffAudio[nBuffAudio] = 0;                 // This works!
                       //BuffAudio[nBuffAudio] = nBuffAudio;       // This works!

                       // Add the delta to the next plot point
                       s_fAccumulator += fInc;
                  }
                  //nBuffAudio = DoSINE(BuffAudio, (sizeof(BuffAudio)/sizeof(BuffAudio[0])), 32000.0, MAX_SAMPLE, s_fAccumulator, 1000.0);
                  iBuffAudio = 0;
             }

 

If I set the Array to less than 1K (the nBuffAudio), even though BuffAudio is declared (fract16)3072, it works.  If I assign an int to BuffAudio, it works.  If I use ANY conversion from the floating point, it crashes with "The call to adi_osal_Init made from the CRT startup code returned an error."

 

CrossCore 1.1.

 

HELP!

 

Thanks.

-Erik

Outcomes