cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476-DISCOVERY cannot be connected to another board via UART

accnt4frms
Associate II
Posted on August 02, 2016 at 23:20

I'm not able to connect STM32L476-DISCOVERY to another board via UART.

For UART4, STMCubeMX suggests to use PA0 as TX pin and PA1 as RX pin and generates unworkable code that transmits data but is not able to receive data.

I suppose that problem in the joystick button that connects to PA1 pin and interferes with UART's RX.

Selecting other UARTs in STMCubeMX tool does't solve the problem.

For USART1 STMCubeMX suggests to use PA10 and PA9 that aren't available on the board.

For UART2: PA0, PA1, PA2, PA3; but it seems that PA1 pin interferes with joystick.

For UART3: PC4, PC5 that also aren't available on the board.

For UART5: PD2, PC12 that aren't available on the board as well.

Is this a feature of the board? Either there is a solution that I don't descry?

#stm32l476-discovery-uart
7 REPLIES 7
Posted on August 03, 2016 at 00:03

It is a heavily populated board, if you aren't using parts of it, remove them. Like the Joystick.. Or find a break-out style board that suits your needs better.

If you are not using the VCP USART, via solder bridges, then consider USART2 using PD5 and PD6

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
accnt4frms
Associate II
Posted on August 03, 2016 at 11:34

I didn't find PD5 and PD6 on the board.

It's sort of turpitude that a debug board cannot be connected via UART.

Posted on August 03, 2016 at 15:22

You should check the solder bridges by the ST-LINK chip. Review the schematic/user manual.

Well the point of a $20 board is you can talk a soldering iron to it without much guilt, compared to a $200 one.

The problem with LCD GLASS is that it eats pins, and you've also got other hardware eating up pins. Decide what you can do without.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
accnt4frms
Associate II
Posted on August 03, 2016 at 19:57

If I paid for it $200 the result would be the same.

Posted on February 08, 2017 at 17:54

I have the same problem.

We need to test the uart output/input. Now I'm ready to change the parts of code that configure usart2. But following the UM1884 manual instructions they seem to be wrong. Since this guide uses HAL_USART API (with the corresponding UARt  typedef struct) but only refers to synchronous parameters and synch modes, not asynch.

I can't find the way of init USART2 with asynch mode. Then I tried doing it with Cube and what a surprise when I see that its C egnerated code uses HAL_UART API, instead the 

HAL_USART (neither the corresponding USARt  typedef struct), as detailed in its own document. But I can't see how must to be configured those GPIOS. 

Have you got the correct way of configuring the USART2, PD5 and PD6 pins?

Posted on February 08, 2017 at 19:36

I don't use HAL/Cube, but can't you look in the Example projects under the L4 Cube Installation for the DISCO, EVAL, and NUCLEO boards, and ports those?

Something like this?

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* User can use this section to tailor USARTx/UARTx instance used and associated
 resources */
/* Definition for USARTx clock resources */
#define USARTx USART2
#define USARTx_CLK_ENABLE() __HAL_RCC_USART2_CLK_ENABLE();
#define USARTx_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define USARTx_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define USARTx_FORCE_RESET() __HAL_RCC_USART2_FORCE_RESET()
#define USARTx_RELEASE_RESET() __HAL_RCC_USART2_RELEASE_RESET()
/* Definition for USARTx Pins */
#define USARTx_TX_PIN GPIO_PIN_5
#define USARTx_TX_GPIO_PORT GPIOD
#define USARTx_TX_AF GPIO_AF7_USART2
#define USARTx_RX_PIN GPIO_PIN_6
#define USARTx_RX_GPIO_PORT GPIOD
#define USARTx_RX_AF GPIO_AF7_USART2
...

/* UART handler declaration */
UART_HandleTypeDef UartHandle;

 /*##-1- Configure the UART peripheral ######################################*/
 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
 /* UART configured as follows:
 - Word Length = 8 Bits
 - Stop Bit = One Stop bit
 - Parity = No parity
 - BaudRate = 9600 baud
 - Hardware flow control disabled (RTS and CTS signals) */
 UartHandle.Instance = USARTx;
 UartHandle.Init.BaudRate = 9600;
 UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
 UartHandle.Init.StopBits = UART_STOPBITS_1;
 UartHandle.Init.Parity = UART_PARITY_NONE;
 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 UartHandle.Init.Mode = UART_MODE_TX_RX;
 if (HAL_UART_Init(&UartHandle) != HAL_OK)
 {
 /* Initialization Error */
 Error_Handler();
 }

...

/**
 * @brief UART MSP Initialization
 * This function configures the hardware resources used in this example:
 * - Peripheral's clock enable
 * - Peripheral's GPIO Configuration
 * @param huart: UART handle pointer
 * @retval None
 */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
 GPIO_InitTypeDef GPIO_InitStruct;

 /*##-1- Enable peripherals and GPIO Clocks #################################*/
 /* Enable GPIO TX/RX clock */
 USARTx_TX_GPIO_CLK_ENABLE();
 USARTx_RX_GPIO_CLK_ENABLE();

 /* Enable USARTx clock */
 USARTx_CLK_ENABLE();
 /*##-2- Configure peripheral GPIO ##########################################*/
 /* UART TX GPIO pin configuration */
 GPIO_InitStruct.Pin = USARTx_TX_PIN;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_PULLUP;
 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
 GPIO_InitStruct.Alternate = USARTx_TX_AF;
 HAL_GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStruct);
 /* UART RX GPIO pin configuration */
 GPIO_InitStruct.Pin = USARTx_RX_PIN;
 GPIO_InitStruct.Alternate = USARTx_RX_AF;
 HAL_GPIO_Init(USARTx_RX_GPIO_PORT, &GPIO_InitStruct);
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on February 28, 2017 at 13:07

Thanks

Turvey.Clive.002

‌, it was so useful.

Now it works correctly.