AnsweredAssumed Answered

UART 1 transmit but the receive data in terminal not same

Question asked by musyafani on Oct 1, 2015
Latest reply on Oct 7, 2015 by Amel N
void UART1_Config(int baudrate){
    __USART1_CLK_ENABLE();
    
    /*---------------GPIO-----------------*/
  GPIO_InitStruct.Pin = (GPIO_PIN_6 | GPIO_PIN_7);
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    /*---------------GPIO-----------------*/
    
    /*##-1- Configure the UART peripheral ######################################*/
  /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
  /* UART1 configured as follow:
      - Word Length = 8 Bits
      - Stop Bit = One Stop bit
      - Parity = ODD parity
      - BaudRate = 9600 baud
      - Hardware flow control disabled (RTS and CTS signals) */
  UartHandle.Instance          = USART1; //enable uart clock
  UartHandle.Init.BaudRate     = baudrate;
  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;
  UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
    
   HAL_UART_Init(&UartHandle);
}


and this is my function to send data .


void SendByte1(unsigned char a) {
    
    while ((USART1->SR & USART_SR_TXE) == 0);
    USART1 -> DR = a ;
    while ((USART1->SR & USART_SR_TXE) == 0);
}


why, if i SendData1(0xFF), in the hyperterminal will receive F0 and always different with thw transmit data.

Outcomes