Reposting as a new topic rather than a post on an old thread :)
The FIFO is critical because at high baud rates (e.g., 460800) firing one interrupt per received character causes too many context switches, especially when multiple serial streams are being received.
However, in the current implementation, interrupt driven serial communications (e.g., with MODSERIAL library) hangs whenever UART FIFO depth is greater than 1, because the CTI (character timeout indication) interrupt is unhandled in serial_api.c . The CTI interrupt should be fired whenever the FIFO is partially filled for longer than a few 'character times'. From the datasheet, exactly [(word length) × 7 - 2] × 8 + [(trigger level - number of characters) × 8 + 1] RCLKs. Because there is valid data in the buffer this interrupt should be handled as if it was a normal read.
So, adding support for the CTI interrupt (for 1768 at least) is a one line fix
serial_api.c snippet
switch (iir) {
case 1: irq_type = TxIrq; break;
case 2: irq_type = RxIrq; break;
+ case 6: irq_type = RxIrq; break;
default: return;
}
Because the exact number of bytes read into the FIFO is unknown, interrupt based serial drivers (e.g., MODSERIAL) must also ensure they loop on .readable() to ensure all bytes are read out to empty the buffer.
An associated feature request would be to add FIFO depth control to the API and document the default initialization to 1 byte length.
Thanks, Matt
Reposting as a new topic rather than a post on an old thread :)
The FIFO is critical because at high baud rates (e.g., 460800) firing one interrupt per received character causes too many context switches, especially when multiple serial streams are being received.
However, in the current implementation, interrupt driven serial communications (e.g., with MODSERIAL library) hangs whenever UART FIFO depth is greater than 1, because the CTI (character timeout indication) interrupt is unhandled in serial_api.c . The CTI interrupt should be fired whenever the FIFO is partially filled for longer than a few 'character times'. From the datasheet, exactly [(word length) × 7 - 2] × 8 + [(trigger level - number of characters) × 8 + 1] RCLKs. Because there is valid data in the buffer this interrupt should be handled as if it was a normal read.
So, adding support for the CTI interrupt (for 1768 at least) is a one line fix
serial_api.c snippet
Because the exact number of bytes read into the FIFO is unknown, interrupt based serial drivers (e.g., MODSERIAL) must also ensure they loop on .readable() to ensure all bytes are read out to empty the buffer.
An associated feature request would be to add FIFO depth control to the API and document the default initialization to 1 byte length.
Thanks, Matt