Proteus和Keil两个软件的联合使用

Proteus和Keil两个软件的联合使用,第1张

Proteus和Keil两个软件的联合使用

(1)Proteus画原理图(Proteus 8 Professional)

 (2)Keil写代码:循环点亮LED灯(Keil uVision5)——这里我只用到了4个LED灯

写完源代码后,检查一下配置,使其能够在Output中输出hex文件。


 

 (3)Keil中编译代码,生成*.hex文件

#include "stm32f10x.h"

void delay(unsigned int count)
{
	unsigned int i;
	for(;count!=0;count--)
	{
		i=5000;
		while(i--);
	}
}

int main(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//时钟
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;//要用到的引脚
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;		//推挽输出
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		//速度50M
	GPIO_Init(GPIOB,&GPIO_InitStructure);								//初始化引脚
	GPIO_SetBits(GPIOB,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3);	//高电平,灯灭
	
	int i,temp;
	
	while(1)
	{ 
		temp=0x0001;				//刚开始:最低位点亮
		for(i=0;i<4;i++)
		{
			GPIO_Write(GPIOB,~temp);//点亮LED
			delay(100);
			temp=temp<<1;//左移1位
		}
	}
}
 (4)双击器件,在Program File位置添加*.hex文件,如下图所示:

注意:运行时如果出错,则需要在其他属性里添加两句话

VDDA=VDD

VSSA=VSS

 (5)Proteus左下角,点击运行

 (6)结果展示:小灯循环点亮了。


 (7)后记:添加了两句话之后的属性(双击查看)

VDDA=VDD

VSSA=VSS

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/568950.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存