Hi Himanshu, Thanks for your reply! I think in the example code there already exists the flag in the adcisr, and once the flag is set, the fft is performed, interrupt void adc_isr(void) { static Uint16 *AdcBufPtr = AdcBuf; // Pointer to ADC data buffer static volatile Uint16 GPIO34_count = 0; // Counter for pin toggle PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Must acknowledge the PIE group //--- Manage the ADC registers AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1 to CONV00 state AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear ADC SEQ1 interrupt flag //--- Read the ADC result *AdcBufPtr++ = AdcMirror.ADCRESULT0; // Read the result //--- Brute-force the circular buffer if( AdcBufPtr == (AdcBuf + ADC_BUF_LEN) ) { AdcBufPtr = AdcBuf; // Rewind the pointer to the beginning FFTStartFlag = 1; // One frame data ready } while(1) // endless loop - wait for an interrupt { if(FFTStartFlag) // If one frame data ready, then do FFT { RFFT_adc_f32u(&rfft_adc); // This version of FFT doesn't need buffer alignment RFFT_f32_mag(&rfft); // Calculate spectrum amplitude j = 1; freq = FFTReal_Magnitude[1]; for(i=2;i freq) { j = i; freq = FFTReal_Magnitude[i]; } } freq = F_PER_SAMPLE * (float)j; //Convert normalized digital frequency to analog frequency FFTStartFlag = 0; //Start collecting the next frame of data } but I still don't quite understand how to read the freq while the program is running, I have to hault it to watch variables. Can you please give some more descriptions? for the ADC module, does it mean that the highest frequency we can sample is 500 kHz or less? Best, Jiangwei
↧