一、建立项目模板

这里的user中重复引用了system_stm32f10x.c

Output中选择Create HEXFile,并且可以选择输出路径。
Listing中可以选择输出路径。
然后在C/C++中加入两个宏:

  1. STM32F10X_MD,USE_STDPERIPH_DRIVER 

并且还要勾选One ELF Section per Function,加入头文件路径:

在Debug中,使用J-Link,并设置
在Utilities,选择J-Link并Setting中:

二、写点LED代码

GPIO初始化:

    /**8位的LED的IO口***/
#define PIN_LED (GPIO_Pin_8 | GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_11 |GPIO_Pin_12 |GPIO_Pin_13 |GPIO_Pin_14 |GPIO_Pin_15)
void LED_INIT(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PIN_LED;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /*打开LED使用的GPIO的时钟使能*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
/*进行初始化*/
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
 

设置多位GPIO电平:

    /****************************
* Function Name : LED_SET
* Description : 设置LED的状态,使用了8位。因为一次使用16位,所以要先读取
* Input : data
* Output : None
* Return : None
*****************************/
void LED_SET(uint8_t data)
{
uint16_t setValue; setValue = GPIO_ReadOutputData(GPIOB);
setValue &= 0x00ff; //使用高8位
setValue |= (uint16_t)data <<; GPIO_Write(GPIOB, setValue);
}

简单的main函数

    /****************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
****************************************************************************/ int main(void)
{
LED_INIT();
LED_SET(0x0f); while ()
{
LED_SET(0xff);
Delay();
LED_SET(0x00);
Delay();
}
} /*******************************************************************************
* Function Name : Delay
* Description : ???±???ò
* Input : c
* Output : None
* Return : None
*******************************************************************************/ void Delay(uint16_t c)
{
uint16_t a,b;
for(; c>; c--)
for(a=; a>; a--)
for(b=; b>; b--);
}
 

可以直接设置单独的GIPO输出位:

    GPIO_WriteBit(GPIOB, GPIO_Pin_15, Bit_SET);
GPIO_WriteBit(GPIOB, GPIO_Pin_15, Bit_RESET);

最新文章

  1. 自定义刷新tableView
  2. 第一章 JavaScript简史
  3. sshd_conf AllowUsers参数
  4. loj 1037(状压dp)
  5. C++网络编程 Java网络编程
  6. Fixing the Great Wall
  7. vim使用总结
  8. 数据文件、日志文件、归档文件、控制文件、参数文件及RMAN备份数据库信息查询
  9. 关于 .crash 分析
  10. strspn 和strcspn
  11. Git学习总结(一)
  12. 用shell制作IP脚本
  13. 电脑中安装多个jdk,eclipse的选择!
  14. linux iso 下载地址
  15. Linux基础学习(5)--文本编辑器Vim
  16. 设计模式【转自JackFrost的博客】
  17. Node.js使用MySQL的连接池
  18. 使用putty连接本地VirtualBox上的centos7 linux主机
  19. Ceph 存储集群 - 存储池
  20. JavaCollection Java 集合框架

热门文章

  1. oracle集合的应用
  2. LDD3 第9章 与硬件通信
  3. node连接mysql数据库
  4. 【Java】SpringBoot 佛祖保佑banner.txt
  5. 纯CSS 常见3D实例
  6. 加载的DAL数据访问层的类型
  7. inline-block,inline,block,table-cell,float
  8. [CF895E] Eyes Closed(线段树,期望)
  9. Ubuntu添加字体
  10. Java必备主流技术流程图,写得非常好!