Skip to content

单片机_stm32f103c8t6_创建工程

[3-2] LED闪烁&LED流水灯&蜂鸣器_哔哩哔哩_bilibili

keil创建工程

编译

添加库文件到项目,

件的include路径

编译器,compiler v6会报错,原因未知 m的 include路径

我这里使用的是 j-link烧录

../p完毕后自动跑程序 IDE创建工程

编译

配置arm compiler编译器 烧录

配置 j-link 路径 和 芯片型号 测试

可以看到小灯在闪烁,说明已经烧录成功

cpp
#include "Delay.h"
#include "stm32f10x.h"                  // Device header
#include "Delay.h"

int main(void)
{
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
    
    GPIO_InitTypeDef GPIO_InitStructure = 
    {
        .GPIO_Mode = GPIO_Mode_Out_PP, // 推挽输出
        .GPIO_Pin = GPIO_Pin_0, 
        .GPIO_Speed = GPIO_Speed_50MHz,
    };
    GPIO_Init(GPIOA,&GPIO_InitStructure);

    while(1)
    {
        GPIO_WriteBit(GPIOA, GPIO_Pin_0, Bit_RESET);
        Delay_ms(500);
        GPIO_WriteBit(GPIOA, GPIO_Pin_0, Bit_SET);      
        Delay_ms(500);
    }
}
最近更新