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.
10 years, 7 months ago.
Serial malfunctions when changing baud rate of other serial port for mBed LPC1549
I am working on mBed LPC1549 platform and try to enable 2 serial ports, one is for debug port and the other is for functional port.
After debugging port is initialized, the debug information can output normally. However, when I change the function port baud rate, the debug port will output unkown code and work abnormally. When I switch the function baud rate back to the SAME baud rate(115200) as debug serial port, the debug serial port works normally again. When I switch the function baud rate back to another baud rate(57600 or 4800) different from the debug port baud rate, the debug serial port still works abnormally.
Below is my test code and log information for your reference(Please note it is based on mBed platfrom):
- include "mbed.h"
- define DBG_PORT_BAUD 115200
- define FUNC_PORT_BAUD1 4800
- define FUNC_PORT_BAUD2 115200 57600
static Serial sSerialDebug(D1, D0); static RawSerial sSerialFunc(D8, D2);
int main(void) { int cnt = 1; int br = FUNC_PORT_BAUD2;
sSerialDebug.baud(115200);
while(1) { if((cnt & 0x7) == 0) { br = br==FUNC_PORT_BAUD2?FUNC_PORT_BAUD1:FUNC_PORT_BAUD2; sSerialDebug.printf("set br %d\r\n", br); sSerialFunc.baud(br); } sSerialDebug.printf("test cnt = %d\r\n", cnt++); wait_ms(1000); } }
The output log is below.
test cnt = 1 test cnt = 2 test cnt = 3 test cnt = 4 test cnt = 5 test cnt = 6 test cnt = 7 set br 4800?磂s?c畉 ?8?磂s?c畉 ?9?磂s?c畉 ?1? 磂s?c畉 ?1? 磂s?c畉 ?1? 磂s?c畉 ?1? 磂s?c畉 ?1? 磂s?c畉 ?1? 砮t燽r€?5?0 test cnt = 16 test cnt = 17 test cnt = 18 test cnt = 19 test cnt = 20 test cnt = 21 test cnt = 22 test cnt = 23 set br 4800?磂s?c畉 ?2? 磂s?c畉 ?2? 磂s?c畉 ?2? 磂s?c畉 ?2? 磂s?c畉 ?2? 磂s?c畉 ?2? 磂s?c畉 ?3? 磂s?c畉 ?3? 砮t€br€?5?0 test cnt = 32 test cnt = 33 test cnt = 34
Could you please help me on this issue?
Thanks.