2024-10-10 02:35 AM
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:
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.:
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:
Additional Information:
Symptoms Observed:
Expected Behavior:
How to Reproduce:
Occurrence:
Any guidance or suggestions on how to troubleshoot or resolve this issue would be greatly appreciated.
2024-10-10 06:27 AM
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.
2024-10-10 08:28 AM
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
2024-10-10 08:38 AM
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.
2024-10-17 05:03 AM
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!
2024-10-17 06:06 AM
@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.
2024-10-17 06:48 AM
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.
2024-10-17 08:11 AM - edited 2024-10-17 08:12 AM
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:
Best Regards.