Skip to main content
PCana.1
Associate
November 29, 2021
Question

How do I have to configure the standard debug PINS (PA13 and PA14) on STM32F030F4P6 if I want to use them as GPIO output?

  • November 29, 2021
  • 4 replies
  • 7077 views

Currently I only set the MODER register to 0 and set the outputs to 0 with the BRR register since I don't need further configurations. I allready use other PINs with the same configuration and they work. I read that this should work, but on my HW it doesn't.

This topic has been closed for replies.

4 replies

Peter BENSCH
Technical Moderator
November 29, 2021

Welcome, @PCana.1​, to the ciommunity!

These pins are the SWD pins, usually used for debugging. It also takes some precautions to use the pins for both debugging and GPIO.

Please note the note in the datasheet under Table 11 if you want to use them:

After reset, these pins are configured as SWDIO and SWCLK alternate functions, and the internal pull-up on SWDIO pin and internal pull-down on SWCLK pin are activated.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
PCana.1
PCana.1Author
Associate
November 29, 2021

Thank you for the quick response.

After every reset i set them as output with the MODER register. I also tried with resetting the PUPDR bits after reset with the same results.

Do you have further suggestions?

Best regards

Peter BENSCH
Technical Moderator
November 29, 2021

What does it mean exactly: "this should work, but on my HW it doesn't", i.e. what output levels do you get?

What else is connected there?

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
PCana.1
PCana.1Author
Associate
November 29, 2021

What does it mean exactly: "this should work, but on my HW it doesn't", i.e. what output levels do you get?

  • I read in the community that setting the pin as output should work
  • the output is zero

What else is connected there?

  • find attached the schematic (out is ouput)0693W00000GZGIyQAP.jpg
waclawek.jan
Super User
November 29, 2021

> After every reset i set them as output with the MODER register.

How, exactly?

JW

PCana.1
PCana.1Author
Associate
November 29, 2021

((RCC->AHBENR) |= (RCC_AHBENR_GPIOAEN))

((GPIOA->MODER) |= (GPIO_MODER_MODER14_0))

((GPIOA->MODER) |= (GPIO_MODER_MODER13_0))

PCana.1
PCana.1Author
Associate
November 29, 2021

after initialization I set them to zero with:

((GPIOA->BRR) |= (GPIO_BSRR_BS_14))

((GPIOA->BRR) |= (GPIO_BSRR_BS_13))

waclawek.jan
Super User
November 29, 2021

> ((GPIOA->MODER) |= (GPIO_MODER_MODER14_0))

> ((GPIOA->MODER) |= (GPIO_MODER_MODER13_0))

As PA13 and PA14 are set to AF after reset, i.e. 0b10, this sets them to 0b11 i.e. Analog, not Out.

JW

PCana.1
PCana.1Author
Associate
November 29, 2021

that sounds legit. I will test it later:)

Thank you very much!!

Best regards