STMicroelectronics / STM32CubeF4

STM32Cube MCU Full Package for the STM32F4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
897 stars 424 forks source link

Unwanted I2S DMA output #168

Open mrx23dot opened 9 months ago

mrx23dot commented 9 months ago

on F401 I setup I2S in slave,fullduplex mode with circular DMA, issue

__HAL_DMA_DISABLE(&hdma_spi2_rx);
__HAL_DMA_DISABLE(&hdma_i2s2_ext_tx);
__HAL_I2S_DISABLE(&hi2s2);

inject more I2S clock in, and DMA still outputs I2S stream to i2s2_ext pin. With unknown const values 2024-02-03_182404_Xi

internal state 2024-02-03_183900_Cv

S4CR.EN is 0!

It should be silent if disabled.

code

  /* i2s uses SPI */
  hi2s2.Instance = SPI2;
  hi2s2.Init.Mode = I2S_MODE_SLAVE_RX;
  hi2s2.Init.Standard = I2S_STANDARD_PHILIPS;
  hi2s2.Init.DataFormat = I2S_DATAFORMAT_32B;
  hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
  hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_44K;
  hi2s2.Init.CPOL = I2S_CPOL_LOW;              /* idle low clock */
  hi2s2.Init.ClockSource = I2S_CLOCK_EXTERNAL; /* not PLL */
  hi2s2.Init.FullDuplexMode = I2S_FULLDUPLEXMODE_ENABLE;
  ASSERT(HAL_I2S_Init(&hi2s2) == HAL_OK);
  __HAL_RCC_I2S_CONFIG(RCC_I2SCLKSOURCE_EXT); 

  /* I2S2_EXT_TX Init */
  hdma_i2s2_ext_tx.Instance = DMA1_Stream4; /* also in task */
  hdma_i2s2_ext_tx.Init.Channel = DMA_CHANNEL_2;
  hdma_i2s2_ext_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
  hdma_i2s2_ext_tx.Init.PeriphInc = DMA_PINC_DISABLE;
  hdma_i2s2_ext_tx.Init.MemInc = DMA_MINC_ENABLE;
  hdma_i2s2_ext_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* 16 even for 32bit */
  hdma_i2s2_ext_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
  hdma_i2s2_ext_tx.Init.Mode = DMA_CIRCULAR;
  hdma_i2s2_ext_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
  hdma_i2s2_ext_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
  ASSERT(HAL_DMA_Init(&hdma_i2s2_ext_tx) == HAL_OK);
  __HAL_LINKDMA(&hi2s2, hdmatx, hdma_i2s2_ext_tx);
  /* DMA1_Stream4_IRQn interrupt configuration */
  HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
KRASTM commented 2 months ago

ST Internal Reference: 188897