-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Description
- Type: Bug
- Target: REALTEK_RTL8195AM
Following example should work on all platforms, but crashes on REALTEK_RTL8195AM.
#include "mbed.h"
int main() {
UARTSerial *serial = new UARTSerial(USBTX, USBRX);
serial->set_baud(115200);
FILE *out = fdopen(serial, "w");
FILE *in = fdopen(serial, "r");
fprintf(out, "Started!\r\n");
while (true) {
int c = fgetc(in);
if (c != EOF) {
fprintf(out, "Input: %c\r\n", c);
} else {
return 0;
}
}
}
This, however works:
#include "mbed.h"
int main() {
UARTSerial *serial = new UARTSerial(USBTX, USBRX);
serial->set_baud(115200);
//FILE *out = fdopen(serial, "w");
FILE *in = fdopen(serial, "r");
printf("Started!\r\n");
while (true) {
int c = fgetc(in);
if (c != EOF) {
printf("Input: %c\r\n", c);
} else {
return 0;
}
}
}
Problem seems to be in the TX interrupt of the serial port.
Following code is able to crash the device using RawSerial:
#include "mbed.h"
int c = 0;
RawSerial *serial;
void tx_avail(void)
{
while (serial->writeable())
serial->putc((c++ % 95) + ' ');
}
int main() {
serial = new RawSerial(USBTX, USBRX, 115200);
core_util_critical_section_enter();
serial->attach(tx_avail, SerialBase::TxIrq);
tx_avail();
core_util_critical_section_exit();
}