⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lis

📁 一个关于AVR单片机的例程
💻 LIS
字号:
                        .module main.c
                        .area text(rom, con, rel)
 0000                   .dbfile E:\avr\2-1-4\main.c
 0000                   .dbfunc e port_init _port_init fV
                        .even
 0000           _port_init::
 0000                   .dbline -1
 0000                   .dbline 24
 0000           ; 
 0000           ; //ICC-AVR application builder : 2007-1-29 10:04:38
 0000           ; // Target : M16
 0000           ; // Crystal: 7.3728Mhz
 0000           ; // 用途:演示通过PINB读按键的值,赋值给PORTA,键盘扫描模型。
 0000           ; // 作者:古欣
 0000           ; // AVR与虚拟仪器 [url]http://www.avrvi.com[/url]
 0000           ; // 使用7.3728M外部晶振,请短接跳线JP2的1和2,电源跳线连接3.3V或者5V
 0000           ; // 开发板连接:LED0~3——PA0~3,独立按键A~D接PB0~3
 0000           ; 
 0000           ; #include <iom16v.h>
 0000           ; #include <macros.h>
 0000           ; 
 0000           ; #define led_port PORTA
 0000           ; //定义输出端口
 0000           ; #define led_ddr DDRA
 0000           ; //定义输出控制寄存器
 0000           ; #define key_PORT PORTB
 0000           ; #define key_DDR DDRB
 0000           ; 
 0000           ; 
 0000           ; 
 0000           ; void port_init(void)
 0000           ; {
 0000                   .dbline 25
 0000           ; PORTA = 0x0F;  //LED灭
 0000 8FE0              ldi R24,15
 0002 8BBB              out 0x1b,R24
 0004                   .dbline 26
 0004           ; DDRA = 0x00;
 0004 2224              clr R2
 0006 2ABA              out 0x1a,R2
 0008                   .dbline 27
 0008           ; PORTB = 0xFF; //按键的端口为输入
 0008 8FEF              ldi R24,255
 000A 88BB              out 0x18,R24
 000C                   .dbline 28
 000C           ; DDRB = 0x00;
 000C 27BA              out 0x17,R2
 000E                   .dbline 29
 000E           ; PORTC = 0x00; //m103 output only
 000E 25BA              out 0x15,R2
 0010                   .dbline 30
 0010           ; DDRC = 0x00;
 0010 24BA              out 0x14,R2
 0012                   .dbline 31
 0012           ; PORTD = 0x00;
 0012 22BA              out 0x12,R2
 0014                   .dbline 32
 0014           ; DDRD = 0x00;
 0014 21BA              out 0x11,R2
 0016                   .dbline 33
 0016           ; led_ddr=0xff; //设置LED的端口为输出
 0016 8ABB              out 0x1a,R24
 0018                   .dbline 34
 0018           ; key_PORT=0x0F; //使能按键的IO口的内部上拉
 0018 8FE0              ldi R24,15
 001A 88BB              out 0x18,R24
 001C                   .dbline -2
 001C           L1:
 001C                   .dbline 0 ; func end
 001C 0895              ret
 001E                   .dbend
 001E                   .dbfunc e init_devices _init_devices fV
                        .even
 001E           _init_devices::
 001E                   .dbline -1
 001E                   .dbline 40
 001E           ; }
 001E           ; 
 001E           ; //call this routine to initialize all peripherals
 001E           ; //此处为ICC系统生成,未做更改
 001E           ; void init_devices(void)
 001E           ; {
 001E                   .dbline 42
 001E           ; //stop errant interrupts until set up
 001E           ; CLI(); //disable all interrupts
 001E F894              cli
 0020                   .dbline 43
 0020           ; port_init();
 0020 EFDF              xcall _port_init
 0022                   .dbline 45
 0022           ; 
 0022           ; MCUCR = 0x00;
 0022 2224              clr R2
 0024 25BE              out 0x35,R2
 0026                   .dbline 46
 0026           ; GICR = 0x00;
 0026 2BBE              out 0x3b,R2
 0028                   .dbline 47
 0028           ; TIMSK = 0x00; //timer interrupt sources
 0028 29BE              out 0x39,R2
 002A                   .dbline 48
 002A           ; SEI(); //re-enable interrupts
 002A 7894              sei
 002C                   .dbline -2
 002C           L2:
 002C                   .dbline 0 ; func end
 002C 0895              ret
 002E                   .dbend
 002E                   .dbfunc e Delay _Delay fV
 002E           ;              j -> R1
 002E           ;              i -> R0
                        .even
 002E           _Delay::
 002E                   .dbline -1
 002E                   .dbline 53
 002E           ; //all peripherals are now initialized
 002E           ; }
 002E           ; 
 002E           ; void Delay(void) //延时,没有详细计算
 002E           ; {
 002E                   .dbline 62
 002E           ; unsigned char i,j;
 002E           ; /*
 002E           ; for(i=20;i>0;i--)
 002E           ; {
 002E           ; for(j=200;j>0;j--)
 002E           ; ;
 002E           ; }
 002E           ; */
 002E           ; ;
 002E                   .dbline -2
 002E           L3:
 002E                   .dbline 0 ; func end
 002E 0895              ret
 0030                   .dbsym l j 1 c
 0030                   .dbsym l i 1 c
 0030                   .dbend
 0030                   .dbfunc e main _main fV
 0030           ;            tmp -> R20
                        .even
 0030           _main::
 0030                   .dbline -1
 0030                   .dbline 66
 0030           ; }
 0030           ; 
 0030           ; void main(void)
 0030           ; {
 0030                   .dbline 67
 0030           ; unsigned char tmp=0; //定义变量
 0030 4427              clr R20
 0032                   .dbline 68
 0032           ; init_devices();     //初始化
 0032 F5DF              xcall _init_devices
 0034 0DC0              xjmp L6
 0036           L5:
 0036                   .dbline 70
 0036           ; while(1)
 0036           ; {
 0036                   .dbline 71
 0036           ;   tmp=(PINB&0x0F); //与0x0F 只取低四位的值
 0036 46B3              in R20,0x16
 0038 4F70              andi R20,15
 003A                   .dbline 72
 003A           ;   if(tmp!=0x0F)
 003A 4F30              cpi R20,15
 003C 41F0              breq L8
 003E                   .dbline 73
 003E           ;   {
 003E                   .dbline 74
 003E           ;   Delay();     //延时去抖
 003E F7DF              xcall _Delay
 0040                   .dbline 75
 0040           ;   if((PINB&0x0F)==tmp) //再次读IO口,如果和上次的值相等,则说明确实是键盘按下
 0040 86B3              in R24,0x16
 0042 8F70              andi R24,15
 0044 8417              cp R24,R20
 0046 19F4              brne L10
 0048                   .dbline 76
 0048           ;   {
 0048                   .dbline 77
 0048           ;   PORTA = tmp&0x0F; //将键盘的值输出到PORTA上
 0048 842F              mov R24,R20
 004A 8F70              andi R24,15
 004C 8BBB              out 0x1b,R24
 004E                   .dbline 78
 004E           ;   }
 004E           L10:
 004E                   .dbline 79
 004E           ;   }
 004E           L8:
 004E                   .dbline 80
 004E EFDF              xcall _Delay
 0050                   .dbline 81
 0050           L6:
 0050                   .dbline 69
 0050 F2CF              xjmp L5
 0052           X0:
 0052                   .dbline -2
 0052           L4:
 0052                   .dbline 0 ; func end
 0052 0895              ret
 0054                   .dbsym r tmp 20 c
 0054                   .dbend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -