#首先看芯片原理图(STM32F103)MINI版
#现在开始配置环境
##现在在桌面上创建一个新的文件夹
##在文件夹里添加五个子文件夹
###core,user,system,fwlib,harware
###core里面需要添加的文件,在STM32库函数里面全部都有
#现在可以打开MDK进行配置了
#ifndef __PMD_H
#define __PMD_H
void PMD_Init(void);
#endif
```c
```c
#include "pmd.h"
#include "stm32f10x.h"
void PMD_Init(void)
{
GPIO_InitTypeDef GPIO_InitTypeStrucre;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitTypeStrucre.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitTypeStrucre.GPIO_Pin=GPIO_Pin_2 ;
GPIO_InitTypeStrucre.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOD,&GPIO_InitTypeStrucre);
GPIO_SetBits(GPIOD,GPIO_Pin_2 );
GPIO_InitTypeStrucre.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitTypeStrucre.GPIO_Pin=GPIO_Pin_8 ;
GPIO_InitTypeStrucre.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitTypeStrucre);
GPIO_SetBits(GPIOA,GPIO_Pin_8 );
}
#include "stm32f10x.h"
#include "delay.h"
#include "pmd.h"
int main(void)
{
PMD_Init();
delay_init();
while(1)
{
PDout(2)=0;
delay_ms(500);
PDout(2)=1;
delay_ms(500);
}
}
#小结:在stm32
库函数使用中,时钟配置,和引脚的初始化非常重要