cancel
Showing results for 
Search instead for 
Did you mean: 

USART3 (PB10, PB11) not working on NUCLEO-G474RE

Aatif Shaikh1
Associate III

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​ 

0693W000008GNhlQAG.png 

/* ----------------------------------------------------------------------------
 *                           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	 		
 
}
 

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @Community member​,

Check that you are using the last version of Cube firmware and STM32CubeMx (that contain a fix with UART/USART LL driver).

Please keep us informed about your progress on this issue. If it is solved, please mark the answer as "Best Answer" by clicking on the "Select as Best" button, this can be very helpful for Community users to find this solution more quickly.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

9 REPLIES 9

So pull a schematic and trace the pin from the IC to the header.

Check you're looking at the right pins. Toggle as a GPIO, send a stream of 'U' characters as a UART, scope the pins.

Not a board I'm using

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee

Hello @Community member​,

Check that you are using the last version of Cube firmware and STM32CubeMx (that contain a fix with UART/USART LL driver).

Please keep us informed about your progress on this issue. If it is solved, please mark the answer as "Best Answer" by clicking on the "Select as Best" button, this can be very helpful for Community users to find this solution more quickly.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Very strange issue! Now when I directly soldered the wires on the pins, it is working properly.

Thanks @Community member​ for sharing your update.

I'm glad to know that your issue is solved :)

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Thank you @Imen DAHMEN​ for your support.

Unfortunately, due to global crises (lead time 35 to 50 weeks) and the unavailability of the ST controller :pensive_face:, the final product is still in the hold state.

could someone enlighten me on the reasons behind all these global crises in the Embedded development section?

​Hi @Community member​ ,

Please contact your local ST sales office for more information regarding availability of the ST products.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
MWiki.1
Associate

Hello, I have question about NUCLEO-F031K6. Can I handle stable serial communication without adding external resistors? (I want to use internal resistors declared in program only, no external). Looking for your answers!

Yes, you can use the internal pull-ups, they work perfectly fine. Additionally, If you are designing your custom-made board, so, I would suggest, go with an external pull-up because you can use them for debugging the UART signals (by using an oscilloscope on them). In case, if you don't want to use the external anymore, you can always replace them with zero ohms resistance.

Great, thank you! :)