USART3 (PB10, PB11) not working on NUCLEO-G474RE
Hello,
I'm working on a NUCLEO-G474RE board (using the LL libraries available on ST site), and I came across an issue, the USART3 available on the PB10 and PB11 is not working. I tried to generate the same code from the CUBEMX as well but unfortunately, no successful outcome so far. In the "User Manual" of this Nucleo board, nothing is specifically mentioned (Jumper settings) regarding the USART3 settings. On the other side, the same USART3 available on PC10, PC11 is working fine and well. As my costume-made boards are already in the fabrication process, could someone please tell me if this issue is related to the Nucleo board or the STM32G4xx series controller?
I'm attaching a code snippet and Nucleo/ Datasheet referential image.
@Community member @Imen DAHMEN @Community member
/* ----------------------------------------------------------------------------
* Includes
* ----------------------------------------------------------------------------
*/
#include "stdint.h"
#include "stm32g474xx.h"
/* ----------------------------------------------------------------------------
* MACROS
* ----------------------------------------------------------------------------
*/
/************ COM PORT USART DEF *****************/
#define _DEBUGG_COM USART3
/************ COM PORT BAUD RATE *****************/
#define _DEBUGG_BAUDRATE0 (uint32_t)115200
/************ COM PORT GPORT ********************/
#define _DEBUGG_GPIO_PORT1 GPIOB
#define _DEBUGG_GPIO_PORT2 GPIOB
/*
//Alt option
#define _DEBUGG_GPIO_PORT1 GPIOC
#define _DEBUGG_GPIO_PORT2 GPIOC
*/
/************ COM PORT PINS ********************/
#define _DEBUGG_GPIO_PIN1 LL_GPIO_PIN_10
#define _DEBUGG_GPIO_PIN2 LL_GPIO_PIN_11
/*
//Alt option
#define _DEBUGG_GPIO_PIN1 LL_GPIO_PIN_10
#define _DEBUGG_GPIO_PIN2 LL_GPIO_PIN_11
*/
/************ COM PORT GPORT CLOCK **************/
#define _DEBUGG_PORT_RCC1 LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
#define _DEBUGG_PORT_RCC2 LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
/*
//Alt option
#define _DEBUGG_PORT_RCC1 LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
#define _DEBUGG_PORT_RCC2 LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
*/
/************ COM PORT RCC CONFIG **************/
#define _DEBUGG_COM_RCC_SOURCE LL_RCC_SetUSARTClockSource(LL_RCC_USART3_CLKSOURCE_PCLK1);
#define _DEBUGG_COM_RCC_ENABLE LL_APB1_GRP1_EnableClock (LL_APB1_GRP1_PERIPH_USART3);
/************ COM PORT IRQ CONFIG **************/
#define _DEBUGG_COM_IRQn USART3_IRQn
#define _DEBUGG_NVIC_PR_MAIN SET //MAIN PRIORITY
#define _DEBUGG_NVIC_PR_ALT RESET //ALT PRIORITY
#define _DEBUGG_IRQHandler USART3_IRQHandler
/************ COM PORT PRINTF PROTO ************/
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/************ xxxxxxxxxxxxxxxxxxxx **************/
#define _DEBUG_ALL_ENABLE_DIABLE if( stVarDebuggPara_All.ucDebuggEnableDisable == SET )
/* ----------------------------------------------------------------------------
* STRUCTURE VARIABLES
* ----------------------------------------------------------------------------
*/
typedef struct
{
uint8_t ucDebuggEnableDisable;
}stDebuggPara_All;
/*Debugg variables*/
stDebuggPara_All stVarDebuggPara_All;
/* ---------------------------------------------------------------------------
* FUNCTIONS DECLARATION
* ----------------------------------------------------------------------------
*/
void FnDefaultComPortConfig(uint8_t ucSelec);
/* ---------------------------------------------------------------------------
* FUNCTIONS DEFINITION
* ----------------------------------------------------------------------------
*/
/*****************************************************************************
**@Function : PUTCHAR_PROTOTYPE
**@Descriptions : printf prototype
**@parameters : None
**@return : None
*****************************************************************************/
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART */
LL_USART_TransmitData8(_DEBUGG_COM, (uint8_t) ch);
while ( LL_USART_IsActiveFlag_TXE(_DEBUGG_COM) == RESET )
{ }
return ch;
}
/*****************************************************************************
**@Function : FnDefaultComPortInit
**@Descriptions : _DEBUGG_COM port init
**@parameters : uint8_t
**@return : None
*****************************************************************************/
void FnDefaultComPortConfig(uint8_t ucSelec)
{
/* USER CODE BEGIN _DEBUGG_COM_Init 0 */
/* USER CODE END _DEBUGG_COM_Init 0 */
LL_USART_InitTypeDef USART_InitStruct = {RESET};
LL_GPIO_InitTypeDef GPIO_InitStruct = {RESET};
/* Peripheral clock enable */
_DEBUGG_COM_RCC_SOURCE _DEBUGG_COM_RCC_ENABLE
_DEBUGG_PORT_RCC1 _DEBUGG_PORT_RCC2
/* COM GPIO Configuration*/
GPIO_InitStruct.Pin = _DEBUGG_GPIO_PIN1 ;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE ;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH ;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL ;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP ;
GPIO_InitStruct.Alternate = LL_GPIO_AF_7 ;
LL_GPIO_Init(_DEBUGG_GPIO_PORT1, &GPIO_InitStruct) ;
/* USER CODE END _DEBUGG_COM_Init 1 */
GPIO_InitStruct.Pin = _DEBUGG_GPIO_PIN2 ;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE ;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH ;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL ;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP ;
GPIO_InitStruct.Alternate = LL_GPIO_AF_7 ;
LL_GPIO_Init(_DEBUGG_GPIO_PORT2, &GPIO_InitStruct) ;
/* USER CODE BEGIN _DEBUGG_COM_Init 1 */
/* USER CODE END _DEBUGG_COM_Init 1 */
USART_InitStruct.BaudRate = _DEBUGG_BAUDRATE0 ;
USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1 ;
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B ;
USART_InitStruct.StopBits = LL_USART_STOPBITS_1 ;
USART_InitStruct.Parity = LL_USART_PARITY_NONE ;
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX ;
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE ;
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_8 ;
LL_USART_Init (_DEBUGG_COM, &USART_InitStruct ) ;
LL_USART_SetTXFIFOThreshold(_DEBUGG_COM, LL_USART_FIFOTHRESHOLD_1_8);
LL_USART_SetRXFIFOThreshold(_DEBUGG_COM, LL_USART_FIFOTHRESHOLD_1_8);
LL_USART_DisableFIFO (_DEBUGG_COM);
LL_USART_ConfigAsyncMode (_DEBUGG_COM);
LL_USART_Enable (_DEBUGG_COM);
/* USART1 interrupt Init */
NVIC_SetPriority (_DEBUGG_COM_IRQn,
NVIC_EncodePriority( NVIC_GetPriorityGrouping()
,_DEBUGG_NVIC_PR_MAIN, _DEBUGG_NVIC_PR_ALT));
NVIC_EnableIRQ (_DEBUGG_COM_IRQn);
LL_USART_EnableIT_RXNE (_DEBUGG_COM);
LL_USART_EnableIT_ERROR (_DEBUGG_COM);
/* Polling _DEBUGG_COM initialisation */
while((!(LL_USART_IsActiveFlag_TEACK(_DEBUGG_COM))) || (!(LL_USART_IsActiveFlag_REACK(_DEBUGG_COM))))
{ }
#if _USE_DEBUG_COM
_DEBUG_ALL_ENABLE_DIABLE
printf("\n\rDDEBUGG COM PORT INIT\n\r");
#endif
}
