cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743ZI Nucleo 144, UART interrupt handling

Manju
Associate II

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

  1. PC tries to do handshaking with MCU through UART by sending out "ping\n" (in python script) through COM port
  2. My MCU should receive complete characters and verify if it is "ping\n" in complete interrupt mode(No DMA and No polling) because I never know when PC tries to communicate till then I got other routines to follow in main.
  3. When I verify if PC is handshaking by sending "ping\n" then I need to continue to communicate with it in same ISR till communication gets over as I have to do other data reception and transfer in same IRQ after handshaking is successful. Its like I keep polling for commands from PC after handshaking is successful and based on commands I respond back with answers

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

0 REPLIES 0