Page 1 of 1

I2S can only enter the interrupt once

Posted: Sun Apr 13, 2025 2:40 pm
by blackberryer
OS : ChibiOS-21.11.3
MCU : STM32F405VGT6

I2S : SPI2 STM32_DMA1_STREAM3 CHANNEL0

I'm writing an I2S driver, using the previous buzzer method, setting DMA, and enabling CIRC and TCIE interrupts, but the test result program can only enter the interrupt once

Code: Select all

#define SPI_I2S_PCM_MODE                      (3 << SPI_I2SCFGR_I2SSTD_Pos)
static const stm32_dma_stream_t* i2s_dma;
void I2S_DMA_init(void *buffer, uint16_t count) {
  // I2S RX DMA setup.
  i2s_dma = dmaStreamAlloc(STM32_I2S_SPI2_RX_DMA_STREAM, STM32_I2S_SPI2_IRQ_PRIORITY, (stm32_dmaisr_t)i2s_dma_complete_handler, NULL);
  dmaStreamSetPeripheral(i2s_dma, &SPI2->DR);
  dmaStreamSetMemory0(i2s_dma, buffer);
  dmaStreamSetTransactionSize(i2s_dma, count);
  // select channel I2S_DMA_CHANNEL
  dmaStreamSetMode( i2s_dma,
                    STM32_DMA_CR_CHSEL(I2S_DMA_CHANNEL)
                  | STM32_DMA_CR_PL(3)       // 3 - Very High
                  | STM32_DMA_CR_PSIZE_HWORD // 16 bit
                  | STM32_DMA_CR_MSIZE_HWORD // 16 bit
                  | STM32_DMA_CR_DIR_P2M     // Read from peripheral
                  | STM32_DMA_CR_MINC        // Memory increment mode
                  | STM32_DMA_CR_CIRC        // Circular mode
                  | STM32_DMA_CR_HTIE        // Half transfer complete interrupt enable
                  | STM32_DMA_CR_TCIE        // Full transfer complete interrupt enable
                  | STM32_DMA_CR_EN );
  // init FIFO to 0 aka only one element
  //dmaStreamSetFIFO(i2s_dma, STM32_DMA_FCR_FTH_1Q);
  dmaStreamEnable(i2s_dma);

  // Starting I2S
  rccEnableSPI2(FALSE);           // Enabling I2S unit clock.
  SPI2->CR1 = 0;                  // CRs settings
  SPI2->CR2 = SPI_CR2_RXDMAEN;    // Enable RX DMA
  SPI2->I2SPR   = 0;              // I2S (re)configuration.
  SPI2->I2SCFGR = 0
    | SPI_I2SCFGR_I2SCFG_0        // 01: Slave - receive
    | SPI_I2SCFGR_I2SMOD          // I2S mode is selected
    | SPI_I2S_PCM_MODE            // I2S PCM standard (DSP mode, short sync)
    | SPI_I2SCFGR_PCMSYNC         // Short sync
    | SPI_I2SCFGR_I2SE            // I2S enable
    ;
}

Re: I2S can only enter the interrupt once

Posted: Sun Apr 13, 2025 3:39 pm
by Giovanni
Hi,

An I2S driver is already included, is it lacking somehow?

Not sure about your problem but you should not specify STM32_DMA_CR_EN to the dmaStreamSetMode(), dmaStreamEnable() does that.

Giovanni

Re: I2S can only enter the interrupt once

Posted: Sun Apr 13, 2025 4:43 pm
by blackberryer
Giovanni wrote:Hi,

An I2S driver is already included, is it lacking somehow?

Not sure about your problem but you should not specify STM32_DMA_CR_EN to the dmaStreamSetMode(), dmaStreamEnable() does that.

Giovanni


Oh, the reason for the current positioning is still I2C, the code chip I2C communication failed, the first time it can be successful, the loop configuration chip fails, I added the delay, and the setting of 100khz also failed, and I have disabled buzzer and ws2812, currently I2C1 control code, I2C2 control touchscreen

Re: I2S can only enter the interrupt once

Posted: Mon Apr 14, 2025 6:36 pm
by blackberryer
blackberryer wrote:
Giovanni wrote:Hi,

An I2S driver is already included, is it lacking somehow?

Not sure about your problem but you should not specify STM32_DMA_CR_EN to the dmaStreamSetMode(), dmaStreamEnable() does that.

Giovanni


Oh, the reason for the current positioning is still I2C, the code chip I2C communication failed, the first time it can be successful, the loop configuration chip fails, I added the delay, and the setting of 100khz also failed, and I have disabled buzzer and ws2812, currently I2C1 control code, I2C2 control touchscreen


I asked a stupid question because I incorrectly manipulated the RESET signal of the code chip in the loop, and now it works fine

Re: I2S can only enter the interrupt once

Posted: Fri May 02, 2025 12:18 pm
by blackberryer
Giovanni wrote:Hi,

An I2S driver is already included, is it lacking somehow?

Not sure about your problem but you should not specify STM32_DMA_CR_EN to the dmaStreamSetMode(), dmaStreamEnable() does that.

Giovanni


At present, I still use ChibiOS-21.11.3, and I am currently doing math on I2S, but I have the same problem as him (viewtopic.php?t=2075), the official link downloaded the CMSIS library, and it cannot be compiled successfully, how can I add the CMSIS library correctly?