Closed sdt99 closed 1 year ago
Hello @sdt99
The length of the data to be transferred is mentioned as being in bytes in the HAL U5 directive.
https://github.com/STMicroelectronics/STM32CubeU5/blob/2e2b3e4733ddcde7af1e91f1c27ef7bea84389ce/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_dma.c#L1585
So, please allow me then to close this issue and thank you for your contribution.
With Regards,
This isn't a bug as such, but it is a trap for anyone porting from STM32L4 (and maybe other older STM32s) to the U5 HAL.
The parameter SrcDataSize in the function
DMA_SetConfig()
has a different meaning from STM32L4 - this is due to the difference between the U5 GPDMA GPDMA_CxBR1 register BNDT field - which is the number of bytes to transfer (RM0456 17.8.12) and the L4 DMA DMA_CNDTRx register NDT field which is the number of DMA transfers (RM0432, 11.6.4).If the source and destination datawidths are both bytes then
DMA_SetConfig()
functions identically on the U5 and L4, but if the datawidth is half-word or word then on the U5 the DMA transfer ends after either 1/2 or 1/4 of the DMA is complete since each transfer counts for 2 or 4 bytes,https://github.com/STMicroelectronics/STM32CubeU5/blob/2e2b3e4733ddcde7af1e91f1c27ef7bea84389ce/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_dma.c#L1588
This difference in functionality affects any callers of either
HAL_DMA_Start()
orHAL_DMA_Start_IT()
. It's possible to fix this with conditional compilation in the application code, but it's not ideal to have a near identical HAL API with different functionality. In theoryDMA_SetConfig()
could read the burst length configured in the hdma struct and multiply the SrcDataSize accordingly and I think that this would lead to a consistent API behavior on the U5 to the L4 - but perhaps it's too late to make this change since it would likely break existing applications. Perhaps a comment above the function prototypes to draw attention to the difference ?