Skip to main content
Dilbert K
Associate III
May 2, 2017
Question

Connect USART2 to external device

  • May 2, 2017
  • 7 replies
  • 1758 views
Posted on May 02, 2017 at 03:03

I am trying to use the Nucleo-F411RE and connect to a UART device.  As started, I am using the example from STM32Cube 'C:\stm32\STM32Cube_FW_F4_V1.15.0\Projects\STM32F411RE-Nucleo\Examples\UART'

I can see the message send to external UART device (terminal) by the 'RX' pin on ST-Link board.

Now, I try to map it to different PIN, so change the following in file

#if 0

#define USARTx_TX_PIN GPIO_PIN_2 // Original setting

#define USARTx_RX_PIN GPIO_PIN_3

#else

#define USARTx_TX_PIN GPIO_PIN_8

#define USARTx_RX_PIN GPIO_PIN_9

#endif

When I connect to D7 on CN9 on the board, I do not see the print out message.

Is there any limitation in which IO pin I could use ??  or there are additional code changes to configure the PINs, like Input/Output in the example code.

Are the Arduino pin are mapped to mcu by default, or some SB bridge need to be changed ?

Thanks for advice

    This topic has been closed for replies.

    7 replies

    Dilbert K
    Dilbert KAuthor
    Associate III
    May 2, 2017
    Posted on May 02, 2017 at 03:42

    Also, as for testing, I tried switching from USART2 to USART1 but did not work either....

    Is there any limitation on what USART being used on certain board ??

    Or I have missed some hidden default setting in the example..

    #if 0

    #define USARTx USART2

    #define USARTx_IRQ USART2_IRQn

    #define USARTx_IRQHandler() USART2_IRQHandler()

    #define USARTx_CLK_ENABLE() __HAL_RCC_USART2_CLK_ENABLE();

    #define USARTx_FORCE_RESET() __HAL_RCC_USART2_FORCE_RESET()

    #define USARTx_RELEASE_RESET() __HAL_RCC_USART2_RELEASE_RESET()

    #define USARTx_TX_AF GPIO_AF7_USART2

    #define USARTx_RX_AF GPIO_AF7_USART2

    #else

    #define USARTx USART1

    #define USARTx_IRQ USART1_IRQn

    #define USARTx_IRQHandler() USART1_IRQHandler()

    #define USARTx_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE();

    #define USARTx_FORCE_RESET() __HAL_RCC_USART1_FORCE_RESET()

    #define USARTx_RELEASE_RESET() __HAL_RCC_USART1_RELEASE_RESET()

    #define USARTx_TX_AF GPIO_AF7_USART1

    #define USARTx_RX_AF GPIO_AF7_USART1

    #endif
    Tesla DeLorean
    Guru
    May 2, 2017
    Posted on May 02, 2017 at 03:58

    >>

    Are the Arduino pin are mapped to mcu by default, or some SB bridge need to be changed ?

    PA2/PA3 share functionality with the VCP from the ST-LINK this can potentially cause some conflicts, the NUCLEO-144 and DISCO boards seem to have done a better job.

    PA8 is connected to a USART? You sure about that, check the data sheet for the chip. Also remember the 401/411 being short changed on USARTs

    PA9 (D8) is USART1_TX, PA10 (D2) is USART1_RX

    I've done hybrid stuff with the NUCLEO-64 boards using USART2_TX PA2 (D1) as a common output (in input to shields) and use USART1_RX PA10 (D2) to get the data back in.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    May 2, 2017
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..