Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
Rx buffer of serial is 16 Byte (chars)?
I wrote bottom code to check the length of serial rx buffer. I can not get the Over 16 chars.
#include "mbed.h" DigitalOut led[]= {LED1, LED2, LED3, LED4}; Serial serial(p9, p10); int main() { serial.baud(115200); char chr[100]; int idx; while(true) { led[0]= !led[0]; wait(10); for(idx= 0; serial.readable(); idx++) chr[idx]= serial.getc(); chr[++idx]= '\0'; for(idx= 0; chr[idx] != '\0'; idx++) serial.putc(chr[idx]); } } // eof
I have 2 questions.
- 1. Internal rx buffer of serial is 16Byte, really?
- 2. Over 16 chars is erased? (Rx buffer overflow?)
I wont to receive 40 chars per line without rx irq attach.
In using mbed official SERIAL, Please teach me how to simple way of receiving 40 chars.
1 Answer
9 years, 1 month ago.
I assume you are using an LPC1768? Yes that has a 16-byte buffer for its RX: I don't think any other MCU at mbed comes even close to that (except some other LPCs with the same UART).
If you want more you will need a software buffer, for example using MODSERIAL or BufferedSerial libraries. But these do use RX interrupts in the background.
Dear Erik Olieman,
I thank for your replay.
Yes, I use an LPC1768. I understand that UART rx buf of other MCU is equal to 16 Byte or under 16 Byte, and I need the feature of software buffer.
I decide to code copying rx buffer to private string (ex. rxStored) with rxIrq attach. Public read() returns rxStored.
I appreciate you teach me.
posted by 28 Oct 2015
16 bytes as a fairly common, that's what the 16550 UART has and that part is the de facto standard for UARTs.
posted by Andy A 27 Oct 2015Dear Andy A,
I understand that 16 Bytes of rx buffer in UART is de-facto standard and fairly-common pattern.
Thanks for your answer.
posted by Akinori Hashimoto 28 Oct 2015