cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Mem_Read_DMA fails to read

DS.4
Senior II

Setup in use:

  • P-NUCLEO-STM32WB development board.
  • X-NUCLEO-NFC04A1 expansion board with software pack ( NFC 4.2.05)
  • Added : DMA support for I2C , .ioc cubeMX image attached.

The issue is that I cannot read the ST25DV ID via I2C DMA read. I simply do not get an answer. While the I2C blocking read works fine.

Simple test code I made:

 // main.c
 
MX_NFC_Init();
 
  /* USER CODE BEGIN 2 */
	uint8_t pData = 0u;
 
        // WORKS!
	if ( HAL_OK != HAL_I2C_Mem_Read(&hi2c1, 0x00AE, 0x0017, 0x0002, &pData, 0x0001, 0x1000) )
	{
	  __NOP();
		assert_param(false);
		return 0u;
	}
	
	pData = 0u;
	
        // DOES NOT WORK.
	if ( HAL_OK != HAL_I2C_Mem_Read_DMA(&hi2c1, 0x00AE, 0x0017, 0x0002, &pData, 0x0001) )
	{
		assert_param(false);
		return 0u;
	}
	
       //STUCK HERE!
	while(!pData)
	{
		
	}
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
  MX_NFC_Process();
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

Anything wrong that I am doing?

0693W00000Y7AjGQAV.png

1 ACCEPTED SOLUTION

Accepted Solutions
DS.4
Senior II

Thanks,

I replaced all the code for the I2C DMA with the code from example: I2C_TwoBoards_CommDMA.

Now it works. Did not have the time to investigate it for a better conclusion.

What I am pretty sure is that CubeMx gives a bad code when:

Adding I2C DMA support for P-NUCLEO-STM32WB development board with X-NUCLEO-NFC04A1 expansion board with software pack ( NFC 4.2.0.5). I guess you guys can test it yourself to check.

View solution in original post

3 REPLIES 3
S.Ma
Principal

Find a bit bamg sw I2C for board bringup. Make sure you have open drain mode gpio and external pull up resistor. Usually with an oscilloscope, I2C messages are easy decoded by just looking....

JL. Lebon
ST Employee

Hello,

Can you put a scope probe on SDA and SCL signals to check that the STM32 is correctly sending the I2C request to the ST25DV when using the DMA I2C read ?

Best regards.

DS.4
Senior II

Thanks,

I replaced all the code for the I2C DMA with the code from example: I2C_TwoBoards_CommDMA.

Now it works. Did not have the time to investigate it for a better conclusion.

What I am pretty sure is that CubeMx gives a bad code when:

Adding I2C DMA support for P-NUCLEO-STM32WB development board with X-NUCLEO-NFC04A1 expansion board with software pack ( NFC 4.2.0.5). I guess you guys can test it yourself to check.