cancel
Showing results for 
Search instead for 
Did you mean: 

The STM32H743 LPuart+DMA_IDLE does not function properly

ymy
Associate II
下面是我的部分函数,普通串口按照这个配置,是可以正常进入回调函数,但是LPuart却不能进入回调函数,不知道问题出在哪里,使用stm32cubemx6.16.0,附件是ioc文件,
 
Post Edited by ST moderator to apply source code formatting and translate from Chinese to English to comply with the community rule:

 

Below are some of my functions. With this configuration, the standard serial port can enter the callback function normally, but LPuart cannot. I'm unsure where the issue lies. Using STM32CubeMX 6.16.0. The attached file is the I/O configuration file.

 
void StartControlPowerTask(void const * argument)
{
  /* USER CODE BEGIN StartControlPowerTask */
HAL_StatusTypeDef ret;
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_IDLE);
__HAL_UART_CLEAR_IDLEFLAG(&hlpuart1);
  ret =   HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1, rxl1_dma_buffer, RX_BUFFER_SIZE);//rs232



    /* Infinite loop */
    for(;;)
    {
        osDelay(1);
    }

  /* USER CODE END StartControlPowerTask */
}
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
    if (huart->Instance == LPUART1)
    {

        HAL_DMA_Abort(huart->hdmarx);

        /* 2. Cache 失效(一次即可,注意对齐) */
        SCB_InvalidateDCache_by_Addr((uint32_t *)rxl1_dma_buffer,      RX_BUFFER_SIZE  );
        /* 4. 重新启动接收 */
        HAL_UARTEx_ReceiveToIdle_DMA(&hlpuart1,    rxl1_dma_buffer,    RX_BUFFER_SIZE
        );
    }
}

void MX_LPUART1_UART_Init(void)
{

/* USER CODE BEGIN LPUART1_Init 0 */

/* USER CODE END LPUART1_Init 0 */

/* USER CODE BEGIN LPUART1_Init 1 */

/* USER CODE END LPUART1_Init 1 */
hlpuart1.Instance = LPUART1;
hlpuart1.Init.BaudRate = 19200;
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
hlpuart1.Init.StopBits = UART_STOPBITS_1;
hlpuart1.Init.Parity = UART_PARITY_NONE;
hlpuart1.Init.Mode = UART_MODE_TX_RX;
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
hlpuart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
hlpuart1.FifoMode = UART_FIFOMODE_DISABLE;
if (HAL_UART_Init(&hlpuart1) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&hlpuart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&hlpuart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_DisableFifoMode(&hlpuart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LPUART1_Init 2 */

/* USER CODE END LPUART1_Init 2 */

}







if(uartHandle->Instance==LPUART1)
{
/* USER CODE BEGIN LPUART1_MspInit 0 */

/* USER CODE END LPUART1_MspInit 0 */

/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}

/* LPUART1 clock enable */
__HAL_RCC_LPUART1_CLK_ENABLE();

__HAL_RCC_GPIOB_CLK_ENABLE();
/**LPUART1 GPIO Configuration
PB6 ------> LPUART1_TX
PB7 ------> LPUART1_RX
*/
GPIO_InitStruct.Pin = RS232_TX_Pin|RS232_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_LPUART;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* LPUART1 DMA Init */
/* LPUART1_RX Init */
hdma_lpuart1_rx.Instance = BDMA_Channel0;
hdma_lpuart1_rx.Init.Request = BDMA_REQUEST_LPUART1_RX;
hdma_lpuart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_lpuart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_lpuart1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_lpuart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_lpuart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_lpuart1_rx.Init.Mode = DMA_NORMAL;
hdma_lpuart1_rx.Init.Priority = DMA_PRIORITY_HIGH;
if (HAL_DMA_Init(&hdma_lpuart1_rx) != HAL_OK)
{
Error_Handler();
}

__HAL_LINKDMA(uartHandle,hdmarx,hdma_lpuart1_rx);

/* LPUART1 interrupt Init */
HAL_NVIC_SetPriority(LPUART1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(LPUART1_IRQn);
/* USER CODE BEGIN LPUART1_MspInit 1 */

/* USER CODE END LPUART1_MspInit 1 */
}
6 REPLIES 6
Andrew Neil
Super User

Before adding the complications of DMA and callbacks, can you get the LPUART working in a basic polled application?

 

From your attached filename, is seems that you are also using LwIP and some RTOS?

If so, again, have you got the basics working first?

 

PS:

You also haven't said anything about your hardware - please see: 

How to write your question to maximize your chances to find a solution

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
ST Employee

@ymy in the title you stated the part number: "STM32H773" no part number with this reference, do you mean STM32H743?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

是stm32H743vit,我已经发现问题了,LPuart使用的DMA是BDMA ,BDMA只能直接连接到SRAM4,我把变量定义到SRAM4内部就行了,非常感谢

是stm32H743vit,其他功能都是正常的,我已经发现问题了,LPuart使用的DMA是BDMA,BDMA只能直接连接到SRAM4,我把变量定义到SRAM4内部就行了,非常感谢af1c9822-3f41-4ed7-96ee-c4a2ae1b238a.png

mƎALLEm
ST Employee

Hello,

Sorry I don't understand Chinese. I've already requested you to write in English.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

The chip I'm using is stm32H743vit. I've identified the issue. The DMA used by LPuart is BDMA. BDMA can only be directly connected to SRAM4. I can simply define the variables within SRAM4. Thank you very much.