AnsweredAssumed Answered

Problem with USART

Question asked by Crazy electron on Mar 15, 2016
Latest reply on Mar 15, 2016 by Crazy electron
HI, I'm trying to develop a simple communication with my laptop sending just one character, the problem is that I need to send the character more than 5 times for reconogise it in the Discovery board, the code is simple.

void USART1init()
usart1.Instance = USART1;
usart1.Init.BaudRate = 9600;
usart1.Init.WordLength = USART_WORDLENGTH_8B;
usart1.Init.StopBits = USART_STOPBITS_1;
usart1.Init.Parity = USART_PARITY_NONE;
usart1.Init.Mode = USART_MODE_TX_RX;
usart1.Init.CLKPolarity = USART_POLARITY_LOW;
usart1.Init.CLKPhase = USART_PHASE_1EDGE;

void USART1_Pins_Init(){
     RCC->AHB1ENR|=RCC_AHB1ENR_GPIOAEN;//Damos reloj al GPIO
     RCC->APB2ENR|=RCC_APB2ENR_USART1EN;//Damos reloj al USART1

     GPIO_InitTypeDef GPIO_InitStruct;

    GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

void Read_Usart1(){

     uint8_t Buffer=0;
     uint16_t Size=1;
     uint32_t Timeout=500;
     if (Buffer=='B')Led_ON();
     if (Buffer=='C')Led_OFF();