I have a LPCXpresso54114 board, I want to use the USART to send/receive data. My problem is I can't get a timeout interrupt when receiving data. I tried the examples from SDK, both interrupt and DMA mode. The problem is that they are interrupted when receive buffer is full, although they are not blocking, but I want to know when the receive is timeout. If I don't want to use a RTOS, how can I implement a USART read timeout interrupt?
My name is Sabina and I'll be happy to assist you. I want to make sure I understand exactly what you are trying to achieve. From what I understand is that you do not want to wait until the buffer is full. Instead use a timeout for varied length data? Is this correct?
Thanks for your reply. Yes, I need a timeout when receiving data, since the length of data is varied.
Do you know how to implement that?
Hope you are doing well. I have reviewed the USART module that the LPC54114 has and unfortunately there is not a register that will help with the timeout value directly. So this will have to be a custom implementation. I think the main idea that you should consider is using the RX interrupt as well as a timer. So you can work with both simultaneously if the timer causes an interrupt first then go ahead and read the FIFO. The RX interrupt can cause the timer to restart or if FIFO is full before your timer causes an interrupt it will also allow you to read it at that point.
It all really depends on how you would like to implement it, but I recommend checking Chapter 15 and 16 for the timers.
Start with the examples provided in the SDK with a normal interrupt and add the timer concept described above.
If you have questions about the implementation or it is not working how you are expecting please let me know with the adjustments you made so I can check it for you.