Skip to content

Run-time error when defining multiple Serial objects #11837

@amitchone

Description

@amitchone

Description of defect

I am working on a project that requires 2 UARTs, one µC<->PC and the other µC<->SARA N211.

Initially, when trying to create two Serial objects as below, the following Fatal Run-time error is produced:

Serial pc(PA_2, PA_3, 9600);
Serial modem(PB_6, PB_7, 9600);

- ++ MbedOS Error Info ++
- Error Status: 0x80FF0100 Code: 256 Module: 255
- Error Message: Fatal Run-time error
- Location: 0x8008781
- Error Value: 0x0
- Current Thread: main  Id: 0x20001CCC Entry: 0x8007241 StackSize: 0x1000 StackMem: 
0x200006D0 SP: 0x200015D4 
- For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=MTB_MURATA_ABZ
- -- MbedOS Error Info --
- Error: new serial object is using same UART as STDIO

I believe that this Run-time error is due to both PB_6/PB_7 and the default STDIO UART pins (PA_9/PA_10) sharing the same hardware peripheral - USART1.

At this point I attempted to override the default STDIO UART pins to pins that used a completely separate hardware peripheral. I tried using PA_0/PA_1 (USART4) and PB_3/PB_4 (USART5). When doing this, we no longer see the Run-time error but, when monitoring either the PC or N211 UART, no output is observed and current consumption of the device increases to ~50mA from ~10mA. It should be noted that the program is running as, if I attempt to periodically send a UART message and attempt to toggle another GPIO pin at the same time (connected to a buzzer) the buzzer beeps at the specified period.

I should confirm that, without overriding the default STDIO UART pins I am able to have a simple UART echo program on my PC UART operating just fine (returning what I type and current consumption as expected), see below:

#include <mbed>

Serial pc(PA_2, PA_3, 9600);

int main() 
{
    while(true)
    {
        if(pc.readable())
        {
            pc.putc(pc.getc());
        }
    }
}

I am using a custom board but have triple-checked the pinout of the processor and footprint (and had this sanity checked by other, real-life, people and all seems to be in check,

Target(s) affected by this defect ?

TARGET_MTB_MURATA_ABZ
Note that I initially discovered this issue whilst using the MTB_MURATA_ABZ as the target but using an STM32L083KZ processor.

I have also verified that the Run-time error issue exists when using a genuine MURATA_ABZ module.

Toolchain(s) (name and version) displaying this defect ?

ARM Compiler v6.11

What version of Mbed-os are you using (tag or sha) ?

5.14.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Clangd 8.0.0

How is this defect reproduced ?

The Run-time error is reproduced as follows:

#include "mbed.h"

Serial pc(PA_2, PA_3, 9600);
Serial modem(PB_6, PB_7, 9600);

int main()
{
    while(true)
    {

    }
}

The increase in current consumption and seemingly broken UART can be reproduced as follows:

  • Override STDIO_UART_TX to either PB_3 or PA_0

  • Override STDIO_UART_RX to either PB_4 or PA_1

    #include "mbed.h"

    Serial pc(PA_2, PA_3, 9600);
    Serial modem(PB_6, PB_7, 9600);

    int main()
    {
    while(true)
    {
    pc.printf("Help!\r\n");
    ThisThread::sleep_for(2000);
    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions