#include 'stm32f10x.h'

int main(void) { // 使能 GPIOC 时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

// 初始化 GPIOC.13 引脚为推挽输出模式
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; // 选择 GPIOC.13 引脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // 推挽输出模式
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 输出速度 50MHz
GPIO_Init(GPIOC, &GPIO_InitStructure); // 初始化 GPIOC.13 引脚

while (1)
{
    GPIO_SetBits(GPIOC, GPIO_Pin_13); // 点亮 LED
    for (int i = 0; i < 1000000; i++); // 延时
    GPIO_ResetBits(GPIOC, GPIO_Pin_13); // 熄灭 LED
    for (int i = 0; i < 1000000; i++); // 延时
}

}

STM32 点亮 LED 程序教程:入门级示例

原文地址: https://www.cveoy.top/t/topic/nDUO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录