cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Low-Power UART Transmission on STM32WLLE5JB

CristianAMM
Associate II

MCU: STM32WLLE5JB

BOARD: CUSTOM HW

 

IDE: STM32CubeIDE Version: 1.16.1

 

Description:

I am currently working with the STM32WLLE5JB microcontroller and attempting to use the Low-Power UART feature. I generated the initialization code using the STM32CubeMX (ioc) tool. My objective is to transmit messages over UART at a baud rate of 4800 bps using the HAL_UART_Transmit_IT function. However, I am experiencing an issue where no output is received when connecting to the terminal.

Observation:

  • When I use the polling-based HAL_UART_Transmit function instead, the message "Hello\n" is transmitted successfully, and I receive the correct output on my terminal.
  • This indicates that the UART is functioning correctly in polling mode, but I cannot achieve successful transmission when using the interrupt mode.

Reference Manual:

I have consulted the reference manual (RM0461) for the STM32WLE5JB MCU, but I did not find any relevant information regarding peripheral settings or troubleshooting steps that could assist me in resolving this issue.:

RM(0461)

Code :

Here is the code from my main application:

 

 

/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef hlpuart1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_LPUART1_UART_Init(void);
/* USER CODE BEGIN PFP */
uint8_t rx_buff[1];
/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_LPUART1_UART_Init();

  /* USER CODE BEGIN 2 */
  char rxBuff[20] = "Hello\n";
  size_t arraySize = strlen(rxBuff);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
      if (hlpuart1.gState == HAL_UART_STATE_READY)
      {
          HAL_UART_Transmit_IT(&hlpuart1, (uint8_t*)rxBuff, arraySize);
      }
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure LSE Drive Capability
  */
  HAL_PWR_EnableBkUpAccess();
  __HAL_RCC_LSEDRIVE_CONFIG(LL_RCC_LSEDRIVE_LOW);

  /** Configure the main internal regulator output voltage
  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.LSEState = RCC_LSE_ON;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK3|RCC_CLOCKTYPE_HCLK
                              |RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
                              |RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.AHBCLK3Divider = RCC_SYSCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief LPUART1 Initialization Function
  * @PAram None
  * @retval None
  */
static 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 = 4800;
  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 */
}

/**
  * @brief GPIO Initialization Function
  * @PAram None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  /* USER CODE BEGIN MX_GPIO_Init_1 */
  /* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();

  /* USER CODE BEGIN MX_GPIO_Init_2 */
  /* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @PAram  file: pointer to the source file name
  * @PAram  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

 

IOC file:

This is the warning I receive:

Screenshot 2024-10-10 111915.pngAdditional Information:

  • I receive a warning in the IOC file, which I have attached.
  • I have performed sanity checks, including verifying UART initialization and confirming that the hardware connections are correct.

Symptoms Observed:

  • No output is received when using HAL_UART_Transmit_IT, while output is received using HAL_UART_Transmit.

Expected Behavior:

  • I expect to receive the transmitted message over UART when using interrupt mode.

How to Reproduce:

  1. Initialize LPUART1 using the generated code.
  2. Attempt to send a message using HAL_UART_Transmit_IT.
  3. Monitor the output on the terminal.

Occurrence:

  • This issue occurs consistently every time I attempt to use interrupt mode.

Any guidance or suggestions on how to troubleshoot or resolve this issue would be greatly appreciated.

7 REPLIES 7
STTwo-32
ST Employee

Hello @CristianAMM and welcome to the ST Community.

First, I suggest you follow one of the UART IT examples here. Also, be attention to the fact that the STM32WLE may have a problem on the LPUART will transmitting on a low baud rate as mentioned on the paragraph 2.9.1 of the ES0506.

Best Regards.

STTwo-32

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.

 

Hi STTwo-32,

I tried using the example you mentioned: STM32CubeWL/Projects/NUCLEO-WL55JC/Examples/UART/UART_HyperTerminal_IT.

However, I encountered the same issue as before. In polling mode, the transmission from the MCU to the PC terminal works, but in interrupt mode, nothing happens—the terminal remains completely empty.

The same problem occurs when using the API to receive data from the PC.

I’ve explored the reference manual and ST documentation but couldn’t find a solution.

Additionally, in the example provided in the GitHub repository, the same pins for UART (GPIOA2, GPIOA3) are used. I also tested using the huart2 peripheral instead of the low-power UART, but the issue persists.

Currently, I'm working with this module for the MCU: MAMWLE Datasheet (mouser.com).

Thank you for your help.

Best regards,
Cristian

Have you tested the same behavior with our Nucleo-WL55JC board. Also, have you locked at the errata that I've mentioned on my first post.

Best Regards.

STTwo-32

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.

CristianAMM
Associate II

Hi STTwo-32,

I also have a Nucleo-WL55JC board. I enabled the development board using the corresponding .ioc file, similar to the previous board. On the Nucleo, the UART interrupt functions works properly in both transmitting and receiving modes using HAL_UART_TRANSMIT_IT and HAL_UART_RECEIVE_IT.

However, there may be something I forgotten in the configuration of the STM32WLExx.

I have reviewed the errata notes, datasheet, and reference manual for the specified MCU, but I still haven't resolved the issue.

Could you provide any additional suggestions or configurations that I might need to work with this MCU?

Thank you!


@CristianAMM wrote:

I also have a Nucleo-WL55JC board. I enabled the development board using the corresponding .ioc file, similar to the previous board. On the Nucleo, the UART interrupt functions works properly in both transmitting and receiving modes using HAL_UART_TRANSMIT_IT and HAL_UART_RECEIVE_IT.!


So do a thorough comparison of what's happening on your custom board against what happens on the Nucleo.

  • Carefully compare the source code;
  • Step through the code in both targets - see where they diverge ...

I can't add anything to what @Andrew Neil said. A good debug and Comparision session should do the  job. 

Best Regards.

STTwo-32

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.

CristianAMM
Associate II

Hi STTwo-32,

could this informations be helpful for my pourpouse? 

"Application configuration recommendations
Application configuration recommendations
Parameter Description:
RCC: Proposed solution to manage RCC.
Modes: Low Speed Clock (LSE): Set value to Crystal Ceramic Resonator
Configuration - Parameters Settings:
   • Flash Latency(WS): 2 WS (3 CPU cycle)
   • Power Regulator Voltage Scale: Scale 1
Clock Configuration panel
   • Set MSI RC to 32MHz
   • Set RTC Clock Mux to LSE


RTC: Proposed solution to manage timer in Low Power mode.
   • For Dual Core operation Runtime Contexts are both Cortex-M4 and Cortex-M0+ and initializer is Cortex-M0+
Modes: Activate Clock Source, Activate Calendar and activate Alarm A (and B for Dual Core) (Internal Alarm A (and B for Dual Core))
User Constants: Add the following Constants
   • Constant Name: RTC_N_PREDIV_S Value: 10
   • Constant Name: RTC_PREDIV_S Value: ((1 << RTC_N_PREDIV_S)-1)
   • Constant Name: RTC_PREDIV_A Value: ((1 << (15-RTC_N_PREDIV_S))-1)
Configuration - Parameters Settings:
   • Asynchronous Predivider value: Set value to RTC_PREDIV_A
   • Bin Mode: Free running Binary mode
   • Alarm A Binary AutoControl: RTC_ALARMSUBSECONDBIN_AUTOCLR_NO
Configuration - NVIC settings:
   • Enable both Interrupts

USART/LPUART: Proposed solution to manage trace.
   • For Dual Core operation: Runtime Contexts is Cortex-M4
Modes: Asynchronous
Configuration - Parameters Settings:
   • If LPUART is selected then set Baud Rate: 9600 Bits/s
Configuration - DMA Settings:
   • Add USARTx_TX DMA Request with Channel configured with DMA1 Channel 5
Configuration - NVIC settings:
   • Enable both Interrupts
Clock Configuration panel
   • If LPUART is selected then set Clock Mux to LSE
NVIC Mode and Configuration panel - Preemption priority management
   • Set preemption Priority for DMA and UART Interrupt to 2

Project Manager- Advanced Settings panel: Generated Function Calls management
   • Untick "Generate Code" for RTC on CortexM4 for Dual Core if you decide to use RTC for Timer and DMA on CortexM0PLUS for Dual Core
   • Tick "Do Not Generate Function Call" for DMA, RTC, SUBGHZ, UART and IPCC(for Dual Core)
   • Untick Visibility for all Function Calls on both cores"

 

I found them in the .ioc application file. 

 

where i found it:

 

Screenshot 2024-10-17 170934.png

 

Best Regards.