Solved
Why does the value of the variable inside the interrupt not change?
In this code, the value of the range variable in the purse does not change correctly. What is the reason?
Board = NUCLEO-F413ZH
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef huart4;
extern volatile uint8_t range;
extern uint8_t first_buffer[5];
extern uint8_t main_buffer[8];
/* USER CODE BEGIN EV */
void UART4_IRQHandler(void)
{
/* USER CODE BEGIN UART4_IRQn 0 */
/* USER CODE END UART4_IRQn 0 */
HAL_UART_IRQHandler(&huart4);
/* USER CODE BEGIN UART4_IRQn 1 */
//__HAL_UART_ENABLE_IT(&huart4, UART_IT_RXNE);
if(range == 0) {
HAL_UART_Receive_IT(&huart4, first_buffer, 5);
range = 1;
}
else if(range == 1){
HAL_UART_Receive_IT(&huart4, main_buffer, 8);
range = 0;
}
/* USER CODE END UART4_IRQn 1 */
}
