Skip to main content
Dinesh Rangaswamy
Associate II
Oct 22, 2019 5:52 AM UTC
Solved

NucleoL4R5ZI - Virtual COM PORT works and LPUART Tx(PG7) Works but Rx(PG8) Not working

Virtual COM port & LPUART Tx(PG7) Works fine, but LPUART Rx(PG8) is not working.

Tried in both Int & polling mode, able to send and receive via Virtual COM port.

Configuration:

static struct MCU_UART_S testIf_UARTStruct =

{

   .TxMode = KISO_HAL_TRANSFER_MODE_POLLING,

   .RxMode = KISO_HAL_TRANSFER_MODE_POLLING,

   .Datarate = 115200U,

   .huart.Instance = LPUART1,

   .huart.Init.BaudRate = 115200U,

   .huart.Init.WordLength = UART_WORDLENGTH_8B,

   .huart.Init.StopBits = UART_STOPBITS_1,

   .huart.Init.Parity = UART_PARITY_NONE,

   .huart.Init.Mode = UART_MODE_TX_RX,

   .huart.Init.HwFlowCtl = UART_HWCONTROL_NONE,

   .huart.Init.OverSampling = UART_OVERSAMPLING_16,

   .huart.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE,

   .huart.Init.ClockPrescaler = UART_PRESCALER_DIV1,

   .huart.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT,

};

Setup Code:

      __HAL_RCC_PWR_CLK_ENABLE();

      HAL_PWREx_EnableVddIO2();

      GPIO_InitTypeDef GPIO_InitStruct = { 0 };

      __LPUART1_CLK_ENABLE();

      __GPIOG_CLK_ENABLE();

      /* UART RX/TX GPIO pin configuration */

       GPIO_OpenClockGate(GPIO_PORT_G, PING_LPUART_TX | PING_LPUART_RX);

      GPIO_InitStruct.Pin      = PING_LPUART_TX | PING_LPUART_RX;

      GPIO_InitStruct.Mode     = GPIO_MODE_AF_PP;

      GPIO_InitStruct.Pull     = GPIO_NOPULL;

      GPIO_InitStruct.Speed    = GPIO_SPEED_HIGH;

      GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;

      HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

Read value in gState & RxState of uart handle both seems to be fine (no error codes). Both gState and RxState has value 32 (initialized state).

This topic has been closed for replies.
Dinesh Rangaswamy
Associate II
Nov 4, 2019 8:17 AM UTC

Used USART3 with pin configurations PD8 and PD9 with GPIO_AF7_USART3, this works fine.

1 reply

Dinesh Rangaswamy
Dinesh RangaswamyAuthorBest answer
Associate II
Nov 4, 2019 8:17 AM UTC

Used USART3 with pin configurations PD8 and PD9 with GPIO_AF7_USART3, this works fine.