2020-08-07 01:10 AM
Hello Community,
I am new to ST MCUs.
I want to receive multiple bytes of dat over UART. The size of the data can vary. So I want to use USART1_IRQHandler() when data is received by MCU over UART.
I am able to get the interrupt correctly, But I can get only 1 Byte data from the interrupt handler. and the interrupt handler is being called 1 time only.
What can be the issue?
Below is my ISR function.
void USART1_IRQHandler(void) //Serial port 1 interrupt service program
{
u8 Res;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
Res =USART_ReceiveData(USART1); //Read the received data
}
}
Solved! Go to Solution.
2020-08-07 07:38 AM
You'll get an interrupt for each byte.
If you're debugging and the program is paused, you may miss some bytes. Perhaps this is the actual issue.
2020-08-07 06:51 AM
Should work. Sure you're not getting a framing error or something else on the line?
2020-08-07 06:56 AM
Thanks @TDK for the response,
I am not getting the any errors.
My issue is that I can only get one byte(first byte of my data) using USART_ReceiveData().
How can I get other bytes received on UART.
Should I get the 4 Interrupt for 4 bytes of data?
Or there is another way to get the remaining data after USART1_IRQHandler() being called.
2020-08-07 07:11 AM
You only get 1 byte per interrupt. If you send 4 bytes, the interrupt will trigger 4 times. You need to ensure your program is quick enough to respond to these.
2020-08-07 07:12 AM
Next time, add your chip part number to your post. Since you're using SPL, I'm assuming it's STM32F4 or earlier.
2020-08-07 07:13 AM
Thanks @TDK ,
I will try to make the ISR as small as possible.
One more question, Should I get 4 interrupt while debugging using ST link also? Or there it will be only one.
2020-08-07 07:15 AM
Ok @TDK ,
Will make sure next time to add chip part.
I am using STM32F107.
2020-08-07 07:38 AM
You'll get an interrupt for each byte.
If you're debugging and the program is paused, you may miss some bytes. Perhaps this is the actual issue.