標(biāo)題:
求助:stm32f103c8t6最小版Led不閃爍
[打印本頁]
作者:
wg2993
時(shí)間:
2021-11-25 22:54
標(biāo)題:
求助:stm32f103c8t6最小版Led不閃爍
stm32f103c8t6最小版:想讓PC13的LED燈閃爍,但加了GPIO_ResetBits(GPIOC, GPIO_Pin_13);之后就常亮,不加它,即使復(fù)位也不亮,求各位大俠幫助,謝謝。代碼如下:
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
51hei圖片_20211125223556.jpg
(81.2 KB, 下載次數(shù): 21)
下載附件
2021-11-25 22:36 上傳
作者:
wskufo
時(shí)間:
2021-11-26 07:42
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(LED_PORT_RCC,ENABLE);
GPIO_InitStructure.GPIO_Pin=LED_PIN;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(LED_PORT,&GPIO_InitStructure);
作者:
wskufo
時(shí)間:
2021-11-26 07:43
#define LED_PORT GPIOC
#define LED_PIN (GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_13|GPIO_Pin_15)
#define LED_PORT_RCC RCC_APB2Periph_GPIOC
作者:
wg2993
時(shí)間:
2021-11-27 13:27
謝謝各位大俠,問題已解決。原因是我將核心板上的PC13當(dāng)成了C13
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1