UART only receive one byte
I'm trying to receive more than 1 byte but it receive only 1 byte. Poll method or IT, it doesn't matter. Always receives 1 byte and writes it in rx_buffer[0]. When I search it I found out the reason is timeout, I increase timeout 1000 from 100ms but nothing changes. Can anyone help me please?
Here is my code for poll
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "string.h"
/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart6;
DMA_HandleTypeDef hdma_usart1_rx;
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART6_UART_Init(void);
USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
char rx_buffer[50];
char tx_buffer[50];
while (1)
{
HAL_UART_Receive(&huart1,(uint8_t*)rx_buffer,4,1000);
memcpy(tx_buffer,rx_buffer,4);
HAL_UART_Transmit(&huart6,(uint8_t*)tx_buffer,strlen(tx_buffer),1000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
