用AVR实现简单按键的程序与proteus的结合

源代码在线查看: main.i

软件大小: 44 K
上传用户: ljw128
关键词: proteus AVR 按键 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				#line 1 "F:\电子设计\proteus\简单按键\main.c"
				
				
				
				
				
				
				
				
				
				
				
				
				
				#line 1 "D:/PROGRA~1/icc/include/iom16v.h"
				
				
				
				
				#line 7 "D:/PROGRA~1/icc/include/iom16v.h"
				
				
				#line 10 "D:/PROGRA~1/icc/include/iom16v.h"
				
				
				#line 13 "D:/PROGRA~1/icc/include/iom16v.h"
				
				
				#line 16 "D:/PROGRA~1/icc/include/iom16v.h"
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				#line 15 "F:\电子设计\proteus\简单按键\main.c"
				#line 1 "D:/PROGRA~1/icc/include/macros.h"
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				#line 35 "D:/PROGRA~1/icc/include/macros.h"
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				void _StackCheck(void);
				void _StackOverflowed(char);
				
				
				
				
				#line 16 "F:\电子设计\proteus\简单按键\main.c"
				
				void port_init(void)
				{
				(*(volatile unsigned char *)0x3B) = 0x0F;
				(*(volatile unsigned char *)0x3A)  = 0x0F;
				(*(volatile unsigned char *)0x38) = 0x0F;
				(*(volatile unsigned char *)0x37)  = 0x00;
				(*(volatile unsigned char *)0x35) = 0x00;
				(*(volatile unsigned char *)0x34)  = 0x00;
				(*(volatile unsigned char *)0x32) = 0xFF;
				(*(volatile unsigned char *)0x31)  = 0x05;
				}
				
				
				void init_devices(void)
				{
				
				 asm("cli");
				 port_init();
				
				(*(volatile unsigned char *)0x55) = 0x00;
				(*(volatile unsigned char *)0x5B)  = 0x00;
				(*(volatile unsigned char *)0x59) = 0x00;
				 asm("sei");
				
				}
				
				void delay(void)
				{
				 unsigned char i;
				 for(i=254;i!=0;i--)
				 {
				  asm("nop");
				 }
				}
				
				void main(void)
				{
				 unsigned char temp;
				 init_devices();
				 while(1)
				 {
				  temp=(*(volatile unsigned char *)0x36);
				  delay();
				  if(temp==(*(volatile unsigned char *)0x36))
				  {
				(*(volatile unsigned char *)0x3B)=(*(volatile unsigned char *)0x36);
				  }
				 }
				}
							

相关资源