这学期我买了两个板子,一个是cc2530一个是stm32的,因为学了两门课,其中cc2530老师讲的还不错,不说废话了。
1 打开keil5 Project New uversion project:
2 复制启动文件到工程下(提前新建一个start文件夹):
将三个文件也复制移动到Start:
然后复制这两个文件到Start:
3 在keil添加刚才复制的文件:
修改文件夹名称为:
右键添加已经有的文件到组里:
添加这些文件:
4 添加头文件路径:
C++ include Paths
5 打开工程文件夹:
新建文件夹:
在Target添加文件夹 改名:
User右键 点击添加新文件:
编译并新建工程
6 连接好stm32 stlink:
别接错了 看好用点心
配置调试器:
每次不用按复位运行:
7 点亮led(寄存器方式):
#include "stm32f10x.h" // Device header
int main(){
RCC->APB2ENR=0x00000010;
GPIOC->CRH=0x00300000;
GPIOC->ODR=0x00002000;
while(1){
}
}
8 点亮led(库函数方式):
新建Library:
复制到Libray:
同样复制inc文件到Library:
keil新建Library:添加刚刚的文件:
复制到User:
User添加刚刚的:
复制字符串,并添加3个路径
编译一下。
#include "stm32f10x.h" // Device header
int main(){
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
GPIO_SetBits(GPIOC,GPIO_Pin_13);
GPIO_ResetBits(GPIOC,GPIO_Pin_13);
while(1){
}
}
反正到这我人已经傻了,一个新建项目就这么多,函数还这么难,吐了