HAL_UARTEx_ReceiveToIdle does not receive data correctly through RS485 IC
I'm using a rs485 IC. I transmit and receive data through it. When I send small amount of data like 10-20 there is no problem but when I try to receive more than 40 HAL_UARTEx_ReceiveToIdle makes nonsense. It receive data different then what I send or does not receive all of the buffer. Actually, I've never face a problem like this before. When I hit the breakpoint to see if it is calls callback, it does not. Also, it does not do the same thing when it only receive. I replaced it with HAL_UART_ReceiveDMA and it works well. I spend several days to understand the problem. Is anyone know why it happened, I'm really wondering the problem. I put my receiver code bellow.
Thank you in advance for your help
void uartReceive(){
HAL_GPIO_WritePin(RS485_EN_GPIO_PORT, RS485_EN_Pin, GPIO_PIN_RESET);
HAL_UARTEx_ReceiveToIdle(&huart1, receiveBuff, 45);
}
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){
if(huart->Instance == USART1){
HAL_UARTEx_ReceiveToIdle(&huart1, receiveBuff, 45);
}
}