Content originally posted in LPCWare by MikeSimmonds on Tue Nov 12 09:51:30 MST 2013
Hi, this may not be how you want or need to handle your serial input, but it works for my environment.
I set up my serial ports to use dma programmed for a fairly large circular buffer. 256 or 512 bytes if memory serves.
That way, no matter what else is going on -- interrupts, heavy bursts of activity, etc. -- the *hardware* keeps
on receiving and only needs to service a comms interrupt once each time the buffer wraps.
In my 'main loop' I poll the hardware buffer as an when convenient or necessary. Obviously, you will need to
use some sort of protocol with your serial messages so you can detect the beginning and end of (or length of)
individual messages. [Note: this polling will involve reading both the current 'dma pointer' and a code maintained
variable as to the last point in the buffer that you have read.]
I amd sorry that I cannot share code examples, but I am working for a commercial project.
Food for thought perhaps. Cheers, Mike.