stm32f103c8t6最小版:想讓PC13的LED燈閃爍,但加了GPIO_ResetBits(GPIOC, GPIO_Pin_13);之后就常亮,不加它,即使復位也不亮,求各位大俠幫助,謝謝。代碼如下:
testLed.c:
#include "Init.h"
#include "stm32f10x.h"
int main()
{
LED_init();
while (1){
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
Delay(1000);
GPIO_SetBits(GPIOC, GPIO_Pin_13);
Delay(1000);
}
}
Init.c:
#include "Init.h"
void LED_init(void)
{
//Config PC13 pin
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void Delay(uint16_t time)
{
uint16_t i=0;
while(time--)
{
i=12000;
while(i--);
}
}
Init.h:
#ifndef _CONFIG_H
#define _CONFIG_H
#include "stm32f10x.h"
#include "stdint.h"
void LED_init(void);
void Delay(uint16_t time);
#endif
|