Skip to main content
dinccagri
Associate
October 25, 2014
Question

SWD Pins Using I/O Problem

  • October 25, 2014
  • 2 replies
  • 740 views
Posted on October 25, 2014 at 22:32

Hi,

I tried and failed, now I'm asking here If someone please could provide. I use STM32F030.  

I want to use SWD pins (SWDIO and SWCLK) as I/O pins. But SWDIO always logic 1, SWCLK 0.

My code:

  RCC->AHB1ENR  |= 0x00000001;   //A port clock enable

  GPIOA->PUPDR   = 0;            //A port No pull up, no pull down  

  GPIOA->MODER  |= 0x04000000;   //A13 output

  GPIOA->ODR    |= 0x00002000;   //A13 logic 1

  GPIOA->MODER  |= 0x10000000;   //A14 output

  GPIOA->ODR    |= 0x00004000;   //A14 logic 1

#swd-pins-using-as-i/o
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    October 26, 2014
    Posted on October 26, 2014 at 16:31

    Perhaps you'd want to mask the bits before ORing in new ones. In other SPL releases there have been examples of turning off the SWD/JTAG interfaces.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    dinccagri
    dinccagriAuthor
    Associate
    October 26, 2014
    Posted on October 26, 2014 at 21:14

    thanks Clive1 for answer.

    Found the problem.first must  GPIO->MODER register reset.

    True code:

      GPIOA->MODER  &= 0xC3FFFFFF;   //A13(SWDIO) ve A14(SWCLK) reset

      GPIOA->MODER  |= 0x14000000;   //A13 ve A14 output 

      GPIOA->PUPDR  &= 0x00000000;   //A port No pull up, no pull down  

      GPIOA->ODR    |=   0x00004000;   //A14 logic 1

      GPIOA->ODR    |=   0x00002000;   //A13 logic 1

    Good working.