cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO pins not working

Posted on May 15, 2018 at 08:58

hi I am new to ARM, and I am just started with STM32F103C8T6 blue pill Board, I am compiling with keil uvision 5 with ST-Link v2 programmer. First, I checked with blink program on pin PC_13, the works good. But then I tried with another program with other pins, none of the pins worked. Pins stayed in 3.3v, not going to LOW state. I also checked with an alternate board but the result was same. I will share my program here, in the below program PC_13 is working, but PB_8 and PB_9 stays in a HIGH state, not going to LOW state,  kindly suggest me the reason,

#include <stm32f10x.h>

static __IO uint32_t TimingDelay;

void Delay_Us(uint32_t nTime);

void Delay_Ms(uint32_t ms);

void SysTick_Handler(void);

void DelayInit(void);

void main()

{

int i=0;

SystemInit();

DelayInit();

RCC->APB2ENR |= RCC_APB2ENR_IOPCEN

RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;

GPIOC->CRH|=(0x33<<20);

GPIOB->CRH|=0x33;

while(1)

{

GPIOC->BRR=(1<<13);

GPIOB->BSRR=(1<<9);

for(int j=0;j<200*32;j++)

{

GPIOB->BSRR=(1<<8);

Delay_Us(200);

GPIOB->BRR=(1<<8);

Delay_Us(200);

}

GPIOC->BSRR=(1<<13);

GPIOB->BRR = (1<<9);

for(int j=0;j<200*32;j++)

{

GPIOB->BSRR=(1<<8);

Delay_Us(200);

GPIOB->BRR=(1<<8);

Delay_Us(200);

}

}

}

void Delay_Us(uint32_t nTime){

TimingDelay = nTime;

while(TimingDelay != 0);

}

void Delay_Ms(uint32_t ms)

{

while (ms--)

{

Delay_Us(1000);

}

}

void SysTick_Handler(void){

if (TimingDelay != 0x00)

TimingDelay --;

}

void DelayInit(void)

{

// Update SystemCoreClock value

SystemCoreClockUpdate();

// Configure the SysTick timer to overflow every 1 us

SysTick_Config(SystemCoreClock / 1000000);

}
3 REPLIES 3
S.Ma
Principal
Posted on May 15, 2018 at 11:49

Make sure the GPIO registers are clock enabled. 

Artur IWANICKI
ST Employee
Posted on May 15, 2018 at 13:42

Hello,

I do not know what you have connected to PC13, but please rememeber that we have total output current limitation for PC13, PC14, PC15. In total its output current is limited to 3mA -> please refer to datasheet (pinout section) for further details. What I would recommend is to change PC13 to other pin if you would like to use it as output.

Best Regards,

Artur

henry.dick
Senior II
Posted on May 15, 2018 at 14:48

1. Look up the datasheet to see what chabges you will need to make to your code to move pins.

2. It may take too long to execute some of those loops.

3. Wow. Look at that systick set up.

Having sone understanding of the hardware would be helpful here