AnsweredAssumed Answered

STM32F401RE-Nucleo USART2 Communication Problem

Question asked by apostolakis.nikolaos on Aug 27, 2016
Latest reply on Aug 28, 2016 by Clive One
I am developing a project on STM32F401RE-Nucleo which is about UART Communication.
In order to know how UART works out, I have implemented my first project.
I have connected D0 to D1 (USART2 RX to TX ) , so that I want to receive what I just sent.
Here is my configuration:

void uart_init() {
    USART_InitTypeDef usart2_init_struct;
    GPIO_InitTypeDef gpioa_init_struct;

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);

    gpioa_init_struct.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
    gpioa_init_struct.GPIO_Speed = GPIO_Speed_2MHz;
    gpioa_init_struct.GPIO_Mode = GPIO_Mode_AF;
    gpioa_init_struct.GPIO_OType = GPIO_OType_PP;
    gpioa_init_struct.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &gpioa_init_struct);

    usart2_init_struct.USART_BaudRate = 9600;
    usart2_init_struct.USART_WordLength = USART_WordLength_8b;
    usart2_init_struct.USART_StopBits = USART_StopBits_1;
    usart2_init_struct.USART_Parity = USART_Parity_No;
    usart2_init_struct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    usart2_init_struct.USART_HardwareFlowControl =

    USART_Init(USART2, &usart2_init_struct);

    NVIC_InitTypeDef NVIC_InitStructure;

    /* Enable the USARTx Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

and my main func:

int main(void) {
    while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) != RESET) {
        USART_SendData(USART2, (uint16_t) 0x00ff);
    while (1)

USART_SendData gets called.
I have also set an USART2_IRQHandler() which however never gets triggered.
That is my problem.

My question is whether it is a software problem or not.
I dont believe it is a hardware problem, because it is just a connection between D0 and D1 ( RX <-> TX )