Interrupt driven serial receive?

MMESSITER

Well-known member
Hello!

Does anyone have experience of creating an interrupted driven serial receive using a Teensy 4.1 or 4.0?

I have found that in some projects, polling is simply insufficiently reliable because at times the processor is simply too busy and misses some important incoming bytes.

If anyone has an example of how to do this, I would really appreciate it! It would save me a lot of time.

(I did do it once before in 1983! But that was an 8250 serial chip with an 8088 processor in an original IBM PC! 😁).

Malcolm Messiter
 
Teensy 4.x serial code is interrupt-driven by default. The RX interrupt service routine puts the received byte into an RX buffer, which is 64 bytes by default. If you can't service the buffer often enough, it will overflow and you will lose bytes, but you can increase the buffer size using function addMemoryForRead() (see link below). If the problem is not that the buffer is overflowing, but rather that you are not servicing UART interrupts because you have interrupts of higher priority and long duration, you'll need to either reduce the priority of some interrupts, or reduce the time spent at high interrupt level.

 
Last edited:
Thank you very much! I’ll try enlarging that RX buffer which I think should fix the issue.

With best wishes

Malcolm
 
Thank you very much! I’ll try enlarging that RX buffer which I think should fix the issue.

With best wishes

Malcolm
 
Back
Top