AnsweredAssumed Answered

Can't get data from UART

Question asked by jaravena on Sep 10, 2014
Latest reply on Sep 11, 2014 by Clive One
I'm trying to get data from the usart by waiting for RXNE to get set, but somehow it doesn't ever happen, and it gets stuck forever waiting. An equivalent program on PC communicates just fine with the same endpoint so it shouldn't be that, it's probably a dumb error on my part, I'm posting some sections of my code in case someone can spot anything iffy:

    GPIO_InitTypeDef GPIO_init_struct;
    USART_InitTypeDef USART_init_struct;
    char rbyte;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

    GPIO_init_struct.GPIO_Pin   = GPIO_Pin_6 | GPIO_Pin_7;
    GPIO_init_struct.GPIO_Mode  = GPIO_Mode_AF;
    GPIO_init_struct.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_init_struct.GPIO_OType = GPIO_OType_PP;
    GPIO_init_struct.GPIO_PuPd  = GPIO_PuPd_UP;

    GPIO_Init(GPIOC, &GPIO_init_struct);

    GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);
    GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);

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

    USART_Init(USART6, &USART_init_struct);

    while(USART_GetFlagStatus(USART6, USART_FLAG_RXNE) == RESET);;;
    rbyte = USART_ReceiveData(USART6);

By the way, I'm using a stm32f4 discovery board, with the StdPeriph 1.3.0 library and GNU Tools for ARM Embedded Processors.