Skip to main content
Visitor II
September 13, 2019
Question

Creating custom STM32L072 board and need advice on the SWO pin

  • September 13, 2019
  • 3 replies
  • 1512 views

I have a custom STM32L072 board I developed and I'm trying to understand the ST-Link/SWD pin layout. Looking at the Discovery board schematics I was able to determine which pins to use for the SWCLK, and SWDIO pins, but there is some confusion on the SWO pin. Based on the schematic, PA10 is used for the SWO pin - but what is this pin supposed to be configured as in code? STM32CubeMX does not give me any options other then 'Serial Wire Debug' in the SYS tabs. PA10 alternate function is USART1_RX but that doesn't seem right for single wire USART.

I have my board configured with USB on PA12/PA11, and SWD on PA15 (SWCLK) and PA13 (SWDIO). Does anyone have any insight on the SWO pin on the STM32L072 chips?

After some reading, it seems I will have full debug functionality with the SWDIO/SWCLK pins using an external STLink USB connector, but I want to make sure before I get the board developed for testing. I should be able to flash from USB regardless, but having the STLink capability would be nice, and having printfs() capability as well.

Thank you for the help.

    This topic has been closed for replies.

    3 replies

    Graduate II
    September 13, 2019

    For me it seems that this MCU doesn't have SWO pin. But I wouldn't think of it as a huge loss... More important is to connect NRST, which is also optional but I highly recommend it.

    Visitor II
    September 14, 2019

    I figured the same. I have been looking for code examples for the built in STLink on the Discovery board but can't find anything. I have the NRST pin connected, but just wondering then - what function should I use to write output in an Error_Handler() function? for example. Will a stdout printf() work as good debug output?

    Graduate II
    September 14, 2019

    The CM0 doesn't support the SWO/SWV channel, you might look at the event recorder, or use a USART. ie PA0 UART4_TX, or LPUART1 via PA13/PA14

    printf() and putchar() depend on you providing plumbing to the libraries. ST frequently uses __io_putchar() and that get calls by _write() in the syscalls.c code for GNU/GCC