AnsweredAssumed Answered

STM32F103 PA15 as GPIO

Question asked by r2d2 on Oct 25, 2012
Latest reply on Oct 25, 2012 by r2d2
Hello,

I’m trying to use PA15 pin as an output on STM32F103CB chip, but with no luck.

Because this pin is shared for JTAG, I must use remapping,

First I enable clocks:
RCC->APB2ENR |= RCC_APB2Periph_TIM1 |
            RCC_APB2Periph_AFIO |
            RCC_APB2Periph_GPIOA;

Then set up AFIO like this:

uint32_t reg = AFIO->MAPR;
    reg &= ~(1<<24 | 1<<26);//JTAG-DP Disabled and SW-DP Enabled
    reg |= (1<<25);
    AFIO->MAPR = reg;

Then i set up GPIOA
    reg = GPIOA->CRH;
    reg |= GPIO_CRH_MODE15;//output 50mhz
    reg &= ~(GPIO_CRH_CNF15);//gpio push-pull
    GPIOA->CRH = reg;

And the damn thing does not work. neither through BSRR/BRR nor ODR

I used the same code on STM32F107RC, and it works.
When i tried on another 103 (STM32F103RB) it also did not work as output

If i do not setup it, the internal pullup works as it should.

Also to mention, other jtag pins PB3 and PB4 works as GPIO as they should.

Any suggestions?

Outcomes