Dear ec.1,
The logger is not enabled in the ST25R3916-DISCO demo and some extra work is required to have it working.
Before you follow the instructions to enable it, please note that no usefull message will be displayed by default.
Thus enabling the logger is pointless unless you want to instrument the code with your own messages.
Knowing that, let's enabling the logger.
1. Initialize the UART1
Copy the following function to your main.c
static void UART1_Init(UART_HandleTypeDef *husart)
{
husart->Instance = USART1;
husart->Init.BaudRate = 115200;
husart->Init.WordLength = UART_WORDLENGTH_8B;
husart->Init.StopBits = UART_STOPBITS_1;
husart->Init.Parity = UART_PARITY_NONE;
husart->Init.Mode = UART_MODE_TX_RX;
husart->Init.HwFlowCtl = UART_HWCONTROL_NONE;
husart->Init.OverSampling = UART_OVERSAMPLING_16;
husart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
husart->AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
HAL_UART_Init(husart);
}
Declares a handle for UART1 (global variable):
UART_HandleTypeDef log_uart;
Then call the init functions from the main:
UART1_Init(&log_uart);
logUsartInit(&log_uart);
2. Initialize the PIO for UART1
In the stm32l4xx_hal_msp.c, in the HAL_UART_MspInit function, adds the following statements:
if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART2_MspInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/* USER CODE END USART2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
/* USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
gpio_initstruct.Pin = GPIO_PIN_6;
gpio_initstruct.Mode = GPIO_MODE_AF_PP;
gpio_initstruct.Pull = GPIO_NOPULL;
gpio_initstruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
gpio_initstruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOB, &gpio_initstruct);
gpio_initstruct.Pin = GPIO_PIN_7;
gpio_initstruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOB, &gpio_initstruct);
}
3. Enable logger
Make sure that USE_LOGGER compilation flag is set to 1
4. Terminal baudrate
To get the output, you should open a terminal on the ST-Link Vitual COM port with a baudrate set to 115200.
Please update this thread if anything is still missing on your side.