2015-11-10 01:24 PM
2015-11-13 07:22 AM
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 :(