cancel
Showing results for 
Search instead for 
Did you mean: 

segmentation fault in HAL_I2S_Transmit_DMA on STM32H503

chriskuku
Senior II

I'm about to program a continously running DMA stream (using GPDMA1 (circularly))  in an STM32H503CBU6. But the start already fails.

 

chriskuku_0-1749314103754.png

during the setup of the i2s->hdmatx pointer is zero causing the crash when it wants to get initialized.

I'm in need of a running example with an I2S device configured with a continously running DMA write stream

with a length of 1 (32 word) to the I2S device. Help urgently needed, please.

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_GPDMA1_Init();
  MX_ICACHE_Init();
  MX_I2C1_Init();
  MX_I2S2_Init();
  MX_TIM1_Init();
  /* USER CODE BEGIN 2 */
      //HAL_I2S_Transmit_IT(&hi2s2, ram_loc, 1);
      HAL_I2S_Transmit_DMA(&hi2s2, ram_loc,1);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
     while (1)
     {

    	 HAL_Delay(10);
    	 ram_loc[0]++,ram_loc[1]++;
	  //HAL_I2S_Transmit_DMA(&hi2s2, ram_loc,1);
	  //HAL_I2S_Transmit_IT(&hi2s2, ram_loc, 1);
	  //HAL_I2S_Transmit(&hi2s2, sine_amplitudes, size,5000);
	  //HAL_I2S_Transmit(&hi2s2, test_amplitudes, 4 ,5000);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    }
  /* USER CODE END 3 */
}

DMA 

6 REPLIES 6
TDK
Super User

Please include your IOC file. The DMA pointer should get initialized in the mspinit function. Needs to be enabled in the IOC.

If you feel a post has answered your question, please click "Accept as Solution".

IOC file attached.

Set up a GPDMA channel to service I2S2_TX requests. You don't have one assigned.

TDK_0-1749322003334.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Ah, thanks. I see "Request configuration", there is SPI2_TX/I2S2_TX ! 
I'll try to get further.  Only about the mode I'm not sure. Wouldn't I have to choose circular mode when the DMA should keep itself ongoing?

Yes, if you want it to continue forever you will need to enable circular mode.

If you feel a post has answered your question, please click "Accept as Solution".

This is the code in main.c I'm using now:

   
uint16_t ram_loc[2] = {0,0};
  //HAL_I2S_Transmit_IT(&hi2s2, ram_loc, 1);
      HAL_I2S_Transmit_DMA(&hi2s2, ram_loc,1); // since circular is configured,
                                       // am I right that the DMA keeps alive itself?
  /* Infinite loop */
 
     while (1)
     {

    	// for testing, increment ram_loc (L+R) by one every 10ms
    	// which should produce a (sawtooth) ramp.
    	// 
    	 HAL_Delay(10);
    	 ram_loc[0]++,ram_loc[1]++;
    	 if(ram_loc[0] == 65535)
    		 ram_loc[0]=ram_loc[1]=0;
	  
    }
  

 

I don't see any data out though at the moment.