I have a program which enables interrupt receive until 250ms passed after message send, and after 250ms it should diable the interrupt and shouldn't receive any message until new message send. I wrote somethnig like that and I think it will work if I can disable Receive_IT but couldn't find anything about it
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
i = rand() % 250 ;
CAN_TxData[0] = i ;
came = 1;
currTime = HAL_GetTick();
HAL_CAN_AddTxMessage(&hcan1, &CAN_TxHeader, CAN_TxData, &CAN_TxMailBox); // yollama kodu
while((HAL_GetTick()-currTime <= 250) && came)
{
HAL_UART_Receive_IT(&huart2, TTL_RxData, 8);
}
if (HAL_GetTick()-currTime > 250)
{
// Here I should disable receive IT
timeoutted ++;
}
}
Since everyone complained about my solution I wanted to clarify my project.
First stm32 will send 8byte data to the second stm32 by using CAN, and second stm32 will send the same data by using USART to the first stm32.
If first stm32 receives the message until 250ms passed after its own message, it will check if its the same message it send or not then record it (correct ++ and wrong ++). But if 250ms passed and first stm32 didn't receive anyhting it says it is timeout and will start the same process again. This will continue.