cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I use my sensors, fft with out blocking each other in Ping Pong Application

anone.1
Associate

Hello everyone, I am trying to make a project with pingpong application. I am trying to add some sensors and fft algorithm in ping pong example.

In normally I can use my FFT algorithm with ADC-DMA in while loop().

  HAL_ADC_Start_DMA(&hadc, (uint32_t*) rxBuf, 8192);
  arm_rfft_fast_init_f32 (&fft_handler, 2048);
  while (1)
  {
	int fft_in_ptr = 0;
	if (callback_state == 1)
	{
	  for (int i=0; i<8192; i=i+4)
	  {
		  fft_in_buf[fft_in_ptr] = (float) ((int) (rxBuf[i]<<16)|rxBuf[i+1]);
		  fft_in_buf[fft_in_ptr] += (float) ((int) (rxBuf[i+2]<<16)|rxBuf[i+3]);
		  fft_in_ptr++;
	  }
	  DoFFT();
	}
	if (callback_state == 2)
	{
	  for (int i=0; i<8192; i=i+4)
	  {
		  fft_in_buf[fft_in_ptr] = (float) ((int) (rxBuf[i]<<16)|rxBuf[i+1]);
		  fft_in_buf[fft_in_ptr] += (float) ((int) (rxBuf[i+2]<<16)|rxBuf[i+3]);
		  fft_in_ptr++;
	  }
	  DoFFT();
	}
  }
}
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
{
	callback_state = 1;
}
 
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	callback_state = 2;
}

I can get frequencies of tone correctly. As you can see, I am using while loop for this. I am confused how can I use this code in ping-pong or other application. What is the best way to use this on ping-pong or similar application?

Should I set another sequencer for it? (but this will block cpu I guess)

So I really need advice when adding this to these application such as ping-pong.

0 REPLIES 0