解决普中stm32F103玄武无法仿真问题
-
问题描述
该开发板可以使用串口下载程序,但是无法仿真。每一次仿真,总是会出现Not a genuine ST Device! Abort connection.
-
解决方法
- 最后按照该仿真器要求配置 keil 一定要看仔细了,按照要求 ,这样就可以使用仿真器了
使用库函数点亮LED灯
- 使用的库文件
- 自己完成函数编写(led.h和led.c)
//led.h
#ifndef __LED_H__
#define __LED_H__
#include "stm32f10x.h"
#define LED1_PIN GPIO_Pin_5
#define LED1_PORT GPIOB
#define LED1_PORT_RCC RCC_APB2Periph_GPIOB
#define LED2_PORT_RCC RCC_APB2Periph_GPIOE
#define LED2_PIN GPIO_Pin_5
#define LED2_PORT GPIOE
void LED_Init(void);
#endif
//led.c
#include "led.h"
/*******************************************************************************
* 函 数 名 : LED_Init
* 函数功能 : LED初始化函数
* 输 入 : 无
* 输 出 : 无
*******************************************************************************/
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;//定义结构体变量
RCC_APB2PeriphClockCmd(LED1_PORT_RCC|LED2_PORT_RCC,ENABLE);
GPIO_InitStructure.GPIO_Pin=LED1_PIN; //选择你要设置的IO口
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; //设置推挽输出模式
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //设置传输速率
GPIO_Init(LED1_PORT,&GPIO_InitStructure); /* 初始化GPIO */
GPIO_SetBits(LED1_PORT,LED1_PIN); //将LED端口拉高,熄灭所有LED
GPIO_InitStructure.GPIO_Pin=LED2_PIN; //选择你要设置的IO口
GPIO_Init(LED2_PORT,&GPIO_InitStructure); /* 初始化GPIO */
GPIO_SetBits(LED2_PORT,LED2_PIN); //将LED端口拉高,熄灭所有LED
}
- 结果展示