Skip to main content
nSTAC.1
Associate
May 22, 2020
Question

Channel 8 (and over) of DMA stream lead to code generation error on UART

  • May 22, 2020
  • 2 replies
  • 1432 views

Hello,

I use:

CubeIDE 1.3.0

STM32Cube_FW_F4_1.25.0

STM32F413CHU

I want to use DMA on UART5 on this uC but generated code does not compile.

Channel used by this UART is DMA1->Stream7->Channel8

I use LL, not HAL for UART.

Into MX_UART5_Init function (Core/Src/usart.c), called in main, there is this following line:

LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_7, DMA_CHANNEL_8);

Unfortunately,DMA_CHANNEL_8 is not defined.

Actually, DMA_CHANNEL_x are not defined. However LL_DMA_CHANNEL_1 to LL_DMA_CHANNEL_7 are defined.

I added LL_DMA_CHANNEL_8 (into Drivers/STM32F4xx_HAL_Driver/STM32F4xx_ll_dma.h):

#define LL_DMA_CHANNEL_8 DMA_SxCR_CHSEL_3

I replaced DMA_CHANNEL_8 to LL_DMA_CHANNEL_8 and my code is compiling.

My code generation produces an error.

Is it a bug?

Thanks for your help.

This topic has been closed for replies.

2 replies

TDK
Super User
May 22, 2020

Appears to be a bug/omission. They are defined within stm32f4xx_hal_dma.h but not within stm32f4xx_ll_dma.h.

#if defined (DMA_SxCR_CHSEL_3)
#define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */
#define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */
#define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10 */
#define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11 */
#define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12 */
#define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13 */
#define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14 */
#define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15 */
#endif /* DMA_SxCR_CHSEL_3 */

"If you feel a post has answered your question, please click ""Accept as Solution""."
nSTAC.1
nSTAC.1Author
Associate
May 25, 2020

Thanks for your help.

I will create a bug report using your answer.

waclawek.jan
Super User
May 22, 2020

> I added LL_DMA_CHANNEL_8 (into Drivers/STM32F4xx_HAL_Driver/STM32F4xx_ll_dma.h):

> #define LL_DMA_CHANNEL_8 DMA_SxCR_CHSEL_3

#define DMA_SxCR_CHSEL_3        0x10000000U

#define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */

To me, these look identical.

> My code generation produces an error.

What does this exactly mean?

Do you need to *generate* the code? Can't you simply compile and run it?

JW

nSTAC.1
nSTAC.1Author
Associate
May 25, 2020

Thanks for your response.

I agree with you but in my project, CubeIDE produces:

#define DMA_SxCR_CHSEL_3        0x10000000U

(into stm32f413xx.h), but not:

#define DMA_CHANNEL_8 0x10000000U

DMA_CHANNEL_8 is not defined at all

That's why I have defined LL_DMA_CHANNEL_8 myself.

Therefore, I can't compile and run the code after CubeIDE code generation (using CubeMX).