AnsweredAssumed Answered

GPIO pins not working

Question asked by GOPALAKRISHNAN THANASEKARAN on May 15, 2018
Latest reply on May 15, 2018 by dhenry

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);
}

Outcomes