Silicon Labs


Silicon Labs a leading provider of microcontroller, sensing and wireless connectivity solutions for the Internet of Things (IoT).

Using stdio on Silicon Labs platforms

When you use printf() or scanf(), you automatically use stdio. On mbed, you expect this to get routed to the virtual serial port which appears when connecting the debugger. This also works on Silicon Labs' EFM32 kits, but there are two caveats.

Board Controller Enable Signal

As seen in the board schematics, the board controller (which is responsible for programming and debugging the target MCU, and supplying the virtual COM port interface) is connected to the stdio serial port of the target through an isolation switch.

This means that in order to use stdio as intended, the enable pin (labeled as EFM_BC_EN) must be set high to close the switch. This is done automatically for you during the initialization of your program, so if you want to keep stdio functionality, you don't have to worry about it. However, if you want to use the signals for something else, you'll have to manually set the enable pin back to low.

Disabling the board controller serial connection on Zero Gecko

DigitalOut bcEnablePin(PA9);

void main(void) {
    //Disable the board controller serial connection
    bcEnablePin = 0;
    
    ...
}

Board controller serial port configuration

Due to limitations of the board controller firmware, it only supports a fixed configuration of 115200 baud, 8 bits, 1 stopbit, and no parity. Even if you change the settings in your terminal program, this will not change the chip's settings.

To correctly handle this, the mbed library for EFM32 automatically sets the stdio peripheral up with these parameters when it is initialized on the stdio pins. Therefore, should you wish to use a serial connection on the same pins, but not connected to the virtual COM port, you have to do two things:

  1. Disable the board controller connection (see above)
  2. Set the baudrate to the required value after initialization

Setting the baudrate on stdio when not using the virtual COM port

DigitalOut bcEnablePin(PA9);
Serial stdSerial(USBTX, USBRX);

void main(void) {
    //Disable the board controller serial connection
    bcEnablePin = 0;
    
    //Set baudrate to the mbed standard 9600
    stdSerial.baud(9600);
    ...
}

Table of pin connections

KitEnable pinEFM32 stdio TX pinEFM32 stdio RX pinPeripheral
Zero Gecko (STK3200)PA9PD4PD5LEUART0
Happy Gecko (STK3400)PA9PF2PA0USART1
Leopard Gecko (STK3600)PF7PE0PE1UART0
Giant Gecko (STK3700)PF7PE0PE1UART0
Wonder Gecko (STK3800)PF7PE0PE1UART0

All wikipages