Questdoino
Questdoino

Reputation: 23

STM32 F103C8T6 not all pins working

I'm using the arduino nano style devboard with STM32F103C8T6 inside. I noticed that some pins withing single port are working correctly, however other ones not working at all. I`m using CMSIS v.5.0.1 library and Keil v.5.23 IDE.

Example:

int main (void){
    RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
    GPIOB->CRL &= ~(GPIO_CRL_MODE3 | GPIO_CRL_MODE4 | GPIO_CRL_MODE5 | GPIO_CRL_CNF3 | GPIO_CRL_CNF4 | GPIO_CRL_CNF5);
    GPIOB->CRL |= (GPIO_CRL_MODE3 | GPIO_CRL_MODE4 | GPIO_CRL_MODE5);
    GPIOB->BSRR = (0x38 << 16);
    while (1){
    }
}

I have got 3 leds connected by cathodes to PB3, PB4 and PB5 through resistors and only that is connected to PB5 is glowing. Reverse connecting (anodes to pins) and driving it high

GPIOB->BSRR = 0x38;

changes nothing, altered output speed and configuring them as open drain output gives no result. I tried toggling pins directly through st-link debug mode - the same result, PB5 works correctly, PB3 - PB4 doesn`t work. I even tried to drive the whole port

int main (void){
    RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
    GPIOB->CRL = 0x55555555;
    GPIOB->BSRR = 0xFFFF << 16;
    while (1){
    }
}

PB3 - PB4 are keeping silence. Of course the leds are operational. Tried the different board - the same effect.

Upvotes: 2

Views: 3225

Answers (1)

user149341
user149341

Reputation:

By default, PB3 and PB4 are used for JTAG debugging, as JTDO and JNTRST (respectively). If you want to use these pins for GPIO, you need to remap them using the SWJ_CFG field in AFIO_MAPR.

Upvotes: 5

Related Questions