cancel
Showing results for 
Search instead for 
Did you mean: 

USART LL_DMA STM32U5

IVent.1
Senior

Hallo, I'm using the Nucleo board for STM32U5, LL drivers for USART1 and DMA.

in my main.c the init function are:

static const char

long_string[] = ""

"What's the problem"

"???????\r\n"

"";

static void MX_USART1_UART_Init(void)

{

 /* USER CODE BEGIN USART1_Init 0 */

 /* USER CODE END USART1_Init 0 */

 LL_USART_InitTypeDef USART_InitStruct = {0};

 LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

 LL_DMA_InitTypeDef DMA_InitStruct = {0};

 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

 /** Initializes the peripherals clock

 */

 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;

 PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;

 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

 {

  Error_Handler();

 }

 /* Peripheral clock enable */

 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);

 LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);

 /**USART1 GPIO Configuration

 PA9  ------> USART1_TX

 PA10  ------> USART1_RX

 */

 GPIO_InitStruct.Pin = LL_GPIO_PIN_9|LL_GPIO_PIN_10;

 GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;

 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;

 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

 GPIO_InitStruct.Pull = LL_GPIO_PULL_DOWN;

 GPIO_InitStruct.Alternate = LL_GPIO_AF_7;

 LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /* USART1 DMA Init */

 /* GPDMA1_REQUEST_USART1_TX Init */

 DMA_InitStruct.SrcAddress = (uint32_t)long_string;

  DMA_InitStruct.DestAddress = 0x00000000U;

 DMA_InitStruct.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;

 DMA_InitStruct.BlkHWRequest = LL_DMA_HWREQUEST_SINGLEBURST;

 DMA_InitStruct.DataAlignment = LL_DMA_DATA_ALIGN_ZEROPADD;

 DMA_InitStruct.SrcBurstLength = 1;

 DMA_InitStruct.DestBurstLength = 1;

 DMA_InitStruct.SrcDataWidth = LL_DMA_SRC_DATAWIDTH_BYTE;

 DMA_InitStruct.DestDataWidth = LL_DMA_DEST_DATAWIDTH_BYTE;

 DMA_InitStruct.SrcIncMode = LL_DMA_SRC_INCREMENT;

 DMA_InitStruct.DestIncMode = LL_DMA_DEST_FIXED;

 DMA_InitStruct.Priority = LL_DMA_LOW_PRIORITY_LOW_WEIGHT;

 DMA_InitStruct.BlkDataLength = 10;

 DMA_InitStruct.TriggerMode = LL_DMA_TRIGM_BLK_TRANSFER;

 DMA_InitStruct.TriggerPolarity = LL_DMA_TRIG_POLARITY_MASKED;

 DMA_InitStruct.TriggerSelection = 0x00000000U;

 DMA_InitStruct.Request = LL_GPDMA1_REQUEST_USART1_TX;

 DMA_InitStruct.TransferEventMode = LL_DMA_TCEM_BLK_TRANSFER;

 DMA_InitStruct.SrcAllocatedPort = LL_DMA_SRC_ALLOCATED_PORT0;

 DMA_InitStruct.DestAllocatedPort = LL_DMA_DEST_ALLOCATED_PORT0;

 DMA_InitStruct.LinkAllocatedPort = LL_DMA_LINK_ALLOCATED_PORT1;

 DMA_InitStruct.LinkStepMode = LL_DMA_LSM_FULL_EXECUTION;

 DMA_InitStruct.LinkedListBaseAddr = 0x00000000U;

 DMA_InitStruct.LinkedListAddrOffset = 0x00000000U;

 LL_DMA_Init(GPDMA1, LL_DMA_CHANNEL_0, &DMA_InitStruct);

 /* USART1 interrupt Init */

 NVIC_SetPriority(USART1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 1));

 NVIC_EnableIRQ(USART1_IRQn);

 /* USER CODE BEGIN USART1_Init 1 */

 /* USER CODE END USART1_Init 1 */

 USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1;

 USART_InitStruct.BaudRate = 115200;

 USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;

 USART_InitStruct.StopBits = LL_USART_STOPBITS_1;

 USART_InitStruct.Parity = LL_USART_PARITY_NONE;

 USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;

 USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;

 USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;

 LL_USART_Init(USART1, &USART_InitStruct);

 LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8);

 LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8);

 LL_USART_DisableFIFO(USART1);

 LL_USART_ConfigAsyncMode(USART1);

 LL_USART_Enable(USART1);

 /* USER CODE BEGIN USART1_Init 2 */

 LL_USART_EnableIT_TC(USART1);

 LL_DMA_EnableIT_HT(GPDMA1, LL_DMA_CHANNEL_0);

 LL_DMA_EnableIT_TC(GPDMA1,LL_DMA_CHANNEL_0);

 LL_DMA_EnableIT_USE(GPDMA1, LL_DMA_CHANNEL_0);

 LL_DMA_EnableIT_ULE(GPDMA1, LL_DMA_CHANNEL_0);

 LL_DMA_EnableIT_DTE(GPDMA1, LL_DMA_CHANNEL_0);

 LL_USART_EnableDMAReq_TX(USART1);

 LL_DMA_EnableChannel(GPDMA1, LL_DMA_CHANNEL_0);

 /* USER CODE END USART1_Init 2 */

}

LL_DMA_IsActiveFlag_DTE becomes active.

What am I doing wrong?

Thnak you

Any help would be appreciated.

 It was missing this

DMA_InitStruct.DestAddress = LL_USART_DMA_GetRegAddr(USART1, LL_USART_DMA_REG_DATA_TRANSMIT);

1 ACCEPTED SOLUTION

Accepted Solutions
Diane POMABIA
ST Employee

Hi @IVent.1​ 

DTEF Flag is set when executing the data transfer from register file fail. You have to check if your DMA Channel is correctly enabled and if you have properly configured your DMA( Destination,...).

Regards

DianeP

View solution in original post

1 REPLY 1
Diane POMABIA
ST Employee

Hi @IVent.1​ 

DTEF Flag is set when executing the data transfer from register file fail. You have to check if your DMA Channel is correctly enabled and if you have properly configured your DMA( Destination,...).

Regards

DianeP