Hello In my project I should read two usart input ports without losing my input data.Each input should gets a string's length of 120 each 10ms.How can I handle both of them?
I think I can do with two thread such as this diagram obrazki.elektroda.pl/7019832800_1473252743.png (does it possible easily or not?)
Or can do it with a simple approach instead of using multi-threading?
Thanks
You can poll the two ports quickly.
Especially if you enable the FIFO so each UART can store multiple characters.
You can use an interrupt handler that gets trigged whenever the UART has data available. Also then, it's best to use the FIFO to allow larger latencies without character loss.
You can configure DMA so the UART sends received data directly to a memory buffer.
Two tasks aren't really well suited for picking up characters from a UART. They are much better for handling the received data at a later stage - such as decoding a protocol. You would want an interrupt handler to pick up the characters and then notify the two tasks that there are data available - having the two tasks poll means they need a huge amount of task switching while lots of poll attempts doesn't find any characters.