一、实验目的
1、了解stm32f103c8t6最小核心板的主要引脚接口;
2、掌握Keil 开发stm32程序的环境搭建和设置;
3、使用GPIO引脚,外接LED灯,编写程序让LED灯周期性亮灭。
二、实验内容
原理图
三、烧录代码
#include "stm32f10x.h" // Device header
#include "Delay.h"
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_2| GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
while (1)
{
GPIO_Write(GPIOA, ~0x0001);
Delay_ms(500);
GPIO_Write(GPIOA, ~0x0004);
Delay_ms(500);
GPIO_Write(GPIOA, ~0x0010);
Delay_ms(500);
}
}
四、参考资料
B站江协科技STM32入门教程3-2
五、总结
通过本次实验,我对STM32有了更深的认识。