STM32L151:HAL_UART_RxCpltCallback called only one time
Hi
I want to use a program i made before with the new IDE 1.8. It should reveive som data with the UART2 until EOL is received.
It works on time and after it throws an interrupt (loops in the void USART2_IRQHandler(void)) but doesn't call the HAL_UART_RxCpltCallback anymore.
I think I tried everything, here some parts of the code:
int main(void)
{
...
HAL_UART_Receive_IT(&huart2, (uint8_t *)Rx_data, 1); //activate UART receive interrupt every time
HAL_NVIC_SetPriority(USART2_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE);
}
while (1)
{
if (Transfer_cplt > 0)// Daten vorhanden
{
... do someting with receive data
}
}
static void MX_UART2_UART_Init(void)
{
huart2.Instance = USART2;
huart2.Init.BaudRate = 19200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
int i;
int Rx_indx=0;
if (huart->Instance == USART2) //KS UART
{
__HAL_UART_DISABLE_IT(&huart2, UART_IT_RXNE);
for(i = 0;i<=sizeof(Rx_data);i++)
{
if (Rx_data[0] == 10 || Rx_data[0] == 13)
{
break;
}
RxBuffer[i]= toupper(Rx_data[0]); //add data to Rx_Buffer
HAL_UART_Receive(&huart2,(uint8_t*) Rx_data, 1,10);
}
Transfer_cplt=1;//transfer complete, data is ready to read
}
__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE);
HAL_UART_Receive_IT(&huart2, (uint8_t *)Rx_data, 1);
}Any Idea'?
