2015-09-30 07:52 PM
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. #stm32halusart2015-10-01 01:29 AM
Hi musyafani,
Did you tried using the HAL function: HAL_UART_Transmit? What do you get as result in this case?-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2015-10-01 10:37 AM
can you show me how to use the hal function with HAL_Uart_Transmit();
2015-10-07 04:49 AM
Hi musyafani
Have a look to any UART example available in STM32CubeF4 (I don't know which parts are you using exactly).There are ones under STM32Cube_FW_F4_V1.8.0\Projects\STM32F4-Discovery\Examples\UART.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.