Re: configuration of uart
Posted: Tue Sep 30, 2014 8:04 pm
phoenix2000 wrote:;) but there still questions doesn't the usart of c18 have a mechanism like this ?
what is rxBuffer.idx ?is it in c18 or another compiler or you define it?
It is difficult for the compiler to provide you with a fully generic interrupt-driven buffered serial port. Just look at how complicated the Windows API is for serial communications. It takes a lot of program memory to provide that level of generality. That is difficult to fit into the memory-constrained microcontrollers.
When I implement an interrupt-driven serial port, I will often have the interrupt service routine perform some of the application-level parsing of the input. This makes it unnecessary to buffer an entire message in RAM. At the very least, you want to let the ISR detect packet termination characters. This does make the ISR less re-useable, but it greatly reduces the demands on memory (both RAM and program).