cancel
Showing results for 
Search instead for 
Did you mean: 

USART RX interrupt - capturing data

rasimoguzturk
Associate III
Posted on July 12, 2013 at 09:46

Hi all,

I am working USART RX interrupt.I am sending command through rs485 interface (usart TX) and waiting(delay) response from external device.What i wonder is , there is a flag for waiting last received data?i dont want to use delay function , i want to end session when last data received from usart rx interrupt.

thanks
3 REPLIES 3
Posted on July 12, 2013 at 13:09

How do you know which is the last byte, other than the passage of time with no data received?

I'd think you need to check in subsequent SysTick ticks, or set up a timer in one-shot mode each time you receive a character as a timeout window for the next.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rasimoguzturk
Associate III
Posted on July 12, 2013 at 16:06

thanks for reply,

i agree with you but in my received streams have different sizes how can surely configuring time or timeout.

ex.

xxxxx\r\n

xxxxxxxxxxx\r\n

xxxxxxxxxxxxxxxxxx\r\n

xxxx\r\n

 they are coming one by one.now i am using ''compare \r\n characters'' and it works properly but i doubt because what if ''\r\n''  set does not come and i miss data..

 

Posted on July 12, 2013 at 17:11

Each symbol is transmitted in a uniform amount of time, if you don't have any inter-symbol gap demarcating one transmission from the next then you're going to have to think a bit harder about how you transmit it to your device, and how your device determines when the transmission has stopped.

If you are basing the line demarcation on CR/LF pairs, then you could accumulate data in a line buffer until you receive them, and then pass the buffer off for processing, or you could process character as they arrive with a state-machine type implementation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..