I2S can only enter the interrupt once

Discussions and support about ChibiOS/RT, the free embedded RTOS.
blackberryer
Posts: 9
Joined: Sat Apr 05, 2025 6:52 pm
Been thanked: 2 times

I2S can only enter the interrupt once

Postby blackberryer » Sun Apr 13, 2025 2:40 pm

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
    ;
}

User avatar
Giovanni
Site Admin
Posts: 14603
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1125 times
Been thanked: 938 times

Re: I2S can only enter the interrupt once

Postby Giovanni » Sun Apr 13, 2025 3:39 pm

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

blackberryer
Posts: 9
Joined: Sat Apr 05, 2025 6:52 pm
Been thanked: 2 times

Re: I2S can only enter the interrupt once

Postby blackberryer » Sun Apr 13, 2025 4:43 pm

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

blackberryer
Posts: 9
Joined: Sat Apr 05, 2025 6:52 pm
Been thanked: 2 times

Re: I2S can only enter the interrupt once

Postby blackberryer » Mon Apr 14, 2025 6:36 pm

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


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 26 guests