cancel
Showing results for 
Search instead for 
Did you mean: 

Clock enable for SWD ports (STM32G0)

AYash.1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4

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

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.
Evangelist III

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.

> SWD pins are special, they have special magic

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

JW