lpcware

Serial malfunctions when changing baud rate of other serial port for mBed LPC1549

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by zhjcpi on Wed May 21 00:03:51 MST 2014
Dear,

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 attached.

Original Attachment has been moved to: demo_01.txt.zip

Outcomes