2020-11-15 12:31 AM
Hello ST family,
I'm working on STM32H743ZI chip for my project. I want to execute simple program which communicates with PC through RS232 UART with configuration of 9600 baud rate, 1 stop bit and no parity and No Fifo used. Functionality should be simple as below
I tried implementing this, but my ISRHandler behaves weird, also I'm not aware how this works in STM32. I can paste simple code of this below here
void UART5_IRQHandler(void)
{
/* USER CODE BEGIN UART5_IRQn 0 */
/* USER CODE END UART5_IRQn 0 */
HAL_UART_IRQHandler(&huart5);
/* USER CODE BEGIN UART5_IRQn 1 */
UART5_InterruptCallback(&huart5); // This function I've written and it is something like below
/* USER CODE END UART5_IRQn 1 */
}
void UART5_InterruptCallback(UART_HandleTypeDef *huart5)
{
uint8_t numberOfBytesExpected = 0;
const uint8_t pairingChar[] = "ping\n";
numberOfBytesExpected = (uint8_t)(sizeof(pairingChar));
if ((HAL_UART_Receive_IT(huart5, &pcComm_buffer[0], (uint16_t)numberOfBytesExpected)) != HAL_OK)
{
// Need to handle error here
}
if ((memcmp(&pcComm_buffer[0], pairingChar, sizeof(pairingChar))) == 0)
{
if ((HAL_UART_Transmit_IT(huart5, (uint8_t *)&pairingChar[0], (uint16_t)(sizeof(pairingChar)-2))) != HAL_OK)
{
Error_Handler();
}
// After handshaking I need to do other activities here based on user input which I shall again poll and receive
}
}
Can someone quickly guide how to go ahead here, sometimes I get Overrun error even when I configured UART clock to 129MHz and few times I get Noise error. What could be possible cause of that?
If anyone has example code on handling IRQ and also complete communication should be continued in ISR till we want to manually exit from there. I tried example codes though but that wasn't useful much.
Thanks in advance for response
Manju