cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX generates incorrect code for the STM32U575 MDF peripheral for multiple filters using DMA

LVan .31
Associate II

I am working with the MDF peripheral and find this to be a great peripheral. However the CubeMX generated code for multiple DMA based filters is not correct.


I am using two filters with DMA and CubeMX generates the following descriptors:

  1. MDF_HandleTypeDef MdfHandle0;
  2. MDF_FilterConfigTypeDef MdfFilterConfig0;
  3. MDF_HandleTypeDef MdfHandle1;
  4. MDF_FilterConfigTypeDef MdfFilterConfig1;
  5. DMA_NodeTypeDef Node_GPDMA1_Channel1;
  6. DMA_QListTypeDef List_GPDMA1_Channel1;
  7. DMA_HandleTypeDef handle_GPDMA1_Channel1;
  8. DMA_NodeTypeDef Node_GPDMA1_Channel0;
  9. DMA_QListTypeDef List_GPDMA1_Channel0;
  10. DMA_HandleTypeDef handle_GPDMA1_Channel0;

 

When starting the application I found that both MdfHandle0 and MdfHandle1 refer the same DMA handle,  handle_GPDMA1_Channel1. Likewise both handle_GPDMA1_Channel0.Parent and handle_GPDMA1_Channel1.Parent refer the same filter handle,  MdfHandle0.

This is caused by generated function HAL_MDF_MspInit which is called when starting a filter using HAL_MDF_AcqStart_DMA. This generated function is executed twice since I use two filters but inside this function the exact same code is executed and no distinction is made whether it is called for filter 0 (MdfHandle0) or filter 1 (MdfHandle1).

In other generated ....MspInit functions a distinction is made based on the peripheral instance the function is called for. For instance for UART's in my code, HAL_UART_MspInit looks like:

...

if(huart->Instance==LPUART1)
{

...;

}

else if(huart->Instance==USART1)

{

...;

}

In order to differentiate between the different UART instances.

 

This however is not done in HAL_MDF_MspInit. Instead of the above use is made of:

if(IS_MDF_INSTANCE(hmdf->Instance)) which is typically used inside the HAL but not in the generated code and using this no different code is generated for the different filter instances.

The same issue applies to HAL_MDF_MspDeInit.

 

I have set the wrong descriptors correct manually after the CubeMX initialization code and everything works as expected.

I am using version 6.10.0 of CubeMX and version 1.4.0 of the STM32U5xx HAL library.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Souhaib MAZHOUD
ST Employee

Hello @LVan .31 

Thank you for bringing this issue to our attention, I will check it internally and get back to you as soon as possible.

Thx

Souhaib

 

View solution in original post

1 REPLY 1
Souhaib MAZHOUD
ST Employee

Hello @LVan .31 

Thank you for bringing this issue to our attention, I will check it internally and get back to you as soon as possible.

Thx

Souhaib