Skip to main content
AYash.1
Associate II
August 27, 2023
Solved

Clock enable for SWD ports (STM32G0)

  • August 27, 2023
  • 3 replies
  • 5803 views

I'm a bit confused about the necessity of clocking the SWD ports using STM32G0B1 chip.

There is a I/O port clock enable register (RCC_IOPENR) that enables the functioning of each of the GPIO ports (Port A - Port F), its reset state is all zeroes, so no port is clocked (including Port A, which pins 13-14 in the "alternate function" mode are SWDCLK/SWDIO ports). But the debugging via STLink seems to work in this default configuration. And the actual RCC_IOPENR register state still contain all zeroes during run time (so port A is still not clocked).

I didn't find any mentions of such an exception made for these particular pins in the RM.

If in CubeIDE I explicitly mark these ports as SWD ports, it then generates the code which enables the Port A clock. But if I comment out it, nothing changes, debugging works either way.

So, are these pins clocked separately from the rest of the port A pins? If not, is port A always clocked? And if yes, can I use other alternate functions on these pins without clocking the whole port A?

This topic has been closed for replies.
Best answer by waclawek.jan

Pins as such don't need to be clocked. The GPIO clock allows you to access the GPIO registers, but once set, you can switch the clock of, if you don't need to read our write them (e.g. if all pins of a port are handled by peripherals). This is mentioned in some low-power AN, I am not going to look it up now.

What Cube/CubeMX does it does not do is not a reference point.

JW

3 replies

waclawek.jan
waclawek.janBest answer
Super User
August 27, 2023

Pins as such don't need to be clocked. The GPIO clock allows you to access the GPIO registers, but once set, you can switch the clock of, if you don't need to read our write them (e.g. if all pins of a port are handled by peripherals). This is mentioned in some low-power AN, I am not going to look it up now.

What Cube/CubeMX does it does not do is not a reference point.

JW

AYash.1
AYash.1Author
Associate II
August 27, 2023

Thanks, that makes sense. So you say if I use some of the pins in the alternate function mode, like I2C or FDCAN (they don't need the GPIO registers), I can not bother with clocking the corresponding port? For some reason I couldn't manage to do it without clocking the ports, but I'll give it one more try right away.

Pavel A.
August 27, 2023

But you need to set these pins to AF, using the pin config registers. For this you need to clock the GPIO port interface.

SWD pins are special, they have special magic that lets the debugger connect even under reset.

waclawek.jan
Super User
August 27, 2023

> SWD pins are special, they have special magic

I wouldn't call their particular reset values "magic"...

JW