2018-05-14 11:58 PM
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_IOPCENRCC->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 valueSystemCoreClockUpdate();// Configure the SysTick timer to overflow every 1 usSysTick_Config(SystemCoreClock / 1000000);}2018-05-15 02:49 AM
Make sure the GPIO registers are clock enabled.
2018-05-15 04:42 AM
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
2018-05-15 05:48 AM
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