¿alguien podría explicar por qué solo puedo recibir 13 caracteres con la interrupción de USART? Uso '\ n' para detectar el final de la cadena.
#defineBUFFER_SIZE100charreceive_buffer[BUFFER_SIZE];charreceive_data;intreceive_index=NULL;intdata_ready_index=NULL;voidUSART2_receive(voidconst*argument){for(;;){if(data_ready_index==1){HAL_UART_Transmit_IT(&huart2,(uint8_t*)"Received data: ", strlen("Received data: "));
HAL_Delay(50);
HAL_UART_Transmit_IT(&huart2, (uint8_t *)receive_buffer, strlen(receive_buffer));
memset(receive_buffer, NULL, sizeof(receive_buffer));
HAL_Delay(50);
HAL_UART_Transmit_IT(&huart2, (uint8_t *)"\r\n", strlen("\r\n"));
data_ready_index = NULL;
}
}
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
if (huart->Instance == USART2){
if (receive_data != 13){
receive_buffer[receive_index++]=receive_data;
}else{
receive_index = NULL;
data_ready_index = 1;
// Received data ready to be processed
}
}
}
void USART2_IRQHandler(void){
HAL_UART_IRQHandler(&huart2);
HAL_UART_Receive_IT(&huart2, (uint8_t *) &receive_data, 1);
}