cancel
Showing results for 
Search instead for 
Did you mean: 

DFSDM STM32F413

JJJJBababy
Associate
while (1) {
if (DmaRecHalfBuffCplt == 1) {
/* Store values on Play buff */
for (int i = 0; i < 1024; i++) {
PlayBuff[2 * i] = (int16_t) SaturaLH((RecBuff[i] >> 8), -32768,
32767);
PlayBuff[(2 * i) + 1] = PlayBuff[2 * i];
}
HAL_UART_Transmit_DMA(&huart1, (uint8_t*) PlayBuff, 4096);
DmaRecHalfBuffCplt = 0;
}
if (DmaRecBuffCplt == 1) {
/* Store values on Play buff */
for (int i = 1024; i < 2048; i++) {
PlayBuff[2 * i] = (int16_t) SaturaLH((RecBuff[i] >> 8), -32768,
32767);
PlayBuff[(2 * i) + 1] = PlayBuff[2 * i];
}
DmaRecBuffCplt = 0;
}
/* USER CODE END WHILE */
}

I try to use the AudioTrack Android SDK api to play the PlayBuff data,but i saw The PlayBuff array consists mainly of repeated values FF 7F 80 00. What could be the reason for this? 

2 REPLIES 2
SofLit
ST Employee

Hello and welcome to the community.

Please read these recommendations on this link on how to post threads on this community, especially the posting of a code source.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
JJJJBababy
Associate
void MX_DFSDM2_Init(void)
{

  /* USER CODE BEGIN DFSDM2_Init 0 */

  /* USER CODE END DFSDM2_Init 0 */

  /* USER CODE BEGIN DFSDM2_Init 1 */

  /* USER CODE END DFSDM2_Init 1 */
  hdfsdm2_filter0.Instance = DFSDM2_Filter0;
  hdfsdm2_filter0.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;
  hdfsdm2_filter0.Init.RegularParam.FastMode = ENABLE;
  hdfsdm2_filter0.Init.RegularParam.DmaMode = ENABLE;
  hdfsdm2_filter0.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC4_ORDER;
  hdfsdm2_filter0.Init.FilterParam.Oversampling = 128;
  hdfsdm2_filter0.Init.FilterParam.IntOversampling = 1;
  if (HAL_DFSDM_FilterInit(&hdfsdm2_filter0) != HAL_OK)
  {
    Error_Handler();
  }
  hdfsdm2_channel1.Instance = DFSDM2_Channel1;
  hdfsdm2_channel1.Init.OutputClock.Activation = ENABLE;
  hdfsdm2_channel1.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO;
  hdfsdm2_channel1.Init.OutputClock.Divider = 10;
  hdfsdm2_channel1.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
  hdfsdm2_channel1.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE;
  hdfsdm2_channel1.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;
  hdfsdm2_channel1.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;
  hdfsdm2_channel1.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
  hdfsdm2_channel1.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER;
  hdfsdm2_channel1.Init.Awd.Oversampling = 1;
  hdfsdm2_channel1.Init.Offset = 0;
  hdfsdm2_channel1.Init.RightBitShift = 0x05;
  if (HAL_DFSDM_ChannelInit(&hdfsdm2_channel1) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_DFSDM_FilterConfigRegChannel(&hdfsdm2_filter0, DFSDM_CHANNEL_1, DFSDM_CONTINUOUS_CONV_ON) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN DFSDM2_Init 2 */

  /* USER CODE END DFSDM2_Init 2 */

}



void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter) {
	DmaRecHalfBuffCplt = 1;
}

void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter) {
	DmaRecBuffCplt = 1;
}