一、原理图分析
- 原理图
STM32端口初始化默认为低电平
如果想要点亮发光二极管就要让单片机输出为1
二、代码实现
- 未函数封装的
#include "stm32f4xx.h" // Device header
int main(void){
GPIO_InitTypeDef GPIO_InitStruct;
//1.使能端口时钟
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOI, ENABLE);
//2.端口寄存器初始化
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_13 ;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType=GPIO_OType_PP;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_25MHz;
GPIO_Init(GPIOC, &GPIO_InitStruct