cancel
Showing results for 
Search instead for 
Did you mean: 

HAL UART PROBLEM ON F103CB

nima2
Associate II
Posted on November 10, 2015 at 22:24

The original post was too long to process during our migration. Please click on the attachment to read the original post.
1 REPLY 1
nima2
Associate II
Posted on November 13, 2015 at 16:22

I changed my code to:

void InitUsart(void) {
__GPIOA_CLK_ENABLE();
/**USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
__USART2_CLK_ENABLE();
UartHandle.Instance = USART2;
UartHandle.Init.BaudRate = 115200;
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;
if (HAL_UART_Init(&UartHandle) != HAL_OK) {
/* Initialization Error */
// Error_Handler();
}
if (HAL_UART_Transmit(&UartHandle, (uint8_t *) ''TEST'', 4,
5000) != HAL_OK) {
/* Transfer error in transmission process */
//Error_Handler();
}
}

and it works fine but I can just send data and still I could not receive data with this code:

HAL_UART_Receive(&UartHandle,(uint8_t *) aRxBuffer, RXBUFFERSIZE, 1000);

always I get time out error(0x03) please help me :(