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

📄 led.lis

📁 AVR单片机源代码,采集按键值,并点亮LED.
💻 LIS
📖 第 1 页 / 共 2 页
字号:
                        .module led.c
                        .area text(rom, con, rel)
 0000                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
                        .area data(ram, con, rel)
 0000                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
 0000           _tmrRollFlag::
 0000                   .blkb 1
                        .area idata
 0000 00                .byte 0
                        .area data(ram, con, rel)
 0001                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
 0001                   .dbsym e tmrRollFlag _tmrRollFlag c
                        .area vector(rom, abs)
                        .org 2
 0002 00C0              rjmp _ISR_int0_handler
                        .area data(ram, con, rel)
 0001                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
                        .area text(rom, con, rel)
 0000                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
 0000                   .dbfunc e ISR_int0_handler _ISR_int0_handler fV
 0000           ;              b -> <dead>
 0000           ;              a -> <dead>
                        .even
 0000           _ISR_int0_handler::
 0000 0A92              st -y,R0
 0002 1A92              st -y,R1
 0004 2A92              st -y,R2
 0006 3A92              st -y,R3
 0008 4A92              st -y,R4
 000A 5A92              st -y,R5
 000C 6A92              st -y,R6
 000E 7A92              st -y,R7
 0010 8A92              st -y,R8
 0012 9A92              st -y,R9
 0014 0A93              st -y,R16
 0016 1A93              st -y,R17
 0018 2A93              st -y,R18
 001A 3A93              st -y,R19
 001C 8A93              st -y,R24
 001E 9A93              st -y,R25
 0020 AA93              st -y,R26
 0022 BA93              st -y,R27
 0024 EA93              st -y,R30
 0026 FA93              st -y,R31
 0028 0FB6              in R0,0x3f
 002A 0A92              st -y,R0
 002C                   .dbline -1
 002C                   .dbline 38
 002C           ; /*-----------------------------------------------------------------------------
 002C           ;  * File: LED01.C
 002C           ;  * Author: David Boydston - Solutions Consulting - http://www.serialio.com
 002C           ;  * Copyright (c) 1999 Solutions Consulting All Rights Reserved.
 002C           ;  *
 002C           ;  * Function: Test the light sequence on Atmel 8515 development board
 002C           ;  * Lights should blink one at a time 'up' from PB0 to PB7 then back 'down'
 002C           ;  * from PB7 to PB0. Then the lights will 'stack up' from PB0 to PB7 and
 002C           ;  * 'stack down' from PB7 to PB0. At any time when the PB2 button is
 002C           ;  * pressed the lights should display with an alternating pattern momentarily
 002C           ;  * then continue with the blinking pattern.
 002C           ;  *
 002C           ;  * See disclaimer at http://www.serialio.com/Legal/SoftDisclaimer.htm
 002C           ;  *---------------------------------------------------------------------------*/
 002C           ; 
 002C           ; #include <io8515v.h>
 002C           ; #include <macros.h>
 002C           ; 
 002C           ; #define CLK_DIV_BY_0          0x01 //rolls at 8.19ms with 4Mhz Clock 
 002C           ; #define CLK_DIV_BY_8          0x02 //rolls at 65.5ms with 4Mhz Clock 
 002C           ; #define CLK_DIV_BY_64         0x03 //rolls at 524ms  with 4Mhz Clock 
 002C           ; #define CLK_DIV_BY_256                0x04 //rolls at 2.1sec with 4Mhz Clock 
 002C           ; #define CLK_DIV_BY_1024               0x05 //rolls at 8.4sec with 4Mhz Clock 
 002C           ; #define TMR1_OVF_INT_ENA      0x80
 002C           ; #define GLOBAL_INT_ENA                0x80
 002C           ; #define INT0_ENA                      0x40
 002C           ; #define INT0_TRIG_FALL_EDGE   0x02
 002C           ; #define INT1_ENA                      0x80
 002C           ; 
 002C           ; unsigned char tmrRollFlag = 0;
 002C           ; 
 002C           ; void delay2(unsigned char);
 002C           ; #pragma interrupt_handler ISR_int0_handler:2
 002C           ; //Note: GIMSK I-bit cleared by MCU on INT and set by MCU on RETI
 002C           ; //Thus there should be no danger of us being involked multiple 
 002C           ; //times by switch bounce (as long as delay is reasonable to see LED)
 002C           ; void ISR_int0_handler()
 002C           ; {
 002C                   .dbline 40
 002C           ;       unsigned char a, b;
 002C           ;       PORTB = 0x55;
 002C 85E5              ldi R24,85
 002E 88BB              out 0x18,R24
 0030                   .dbline 41
 0030           ;       delay2(5); //doing this in ISR causes heavy stack use.
 0030 05E0              ldi R16,5
 0032 37D0              rcall _delay2
 0034                   .dbline -2
 0034           L1:
 0034                   .dbline 0 ; func end
 0034 0990              ld R0,y+
 0036 0FBE              out 0x3f,R0
 0038 F991              ld R31,y+
 003A E991              ld R30,y+
 003C B991              ld R27,y+
 003E A991              ld R26,y+
 0040 9991              ld R25,y+
 0042 8991              ld R24,y+
 0044 3991              ld R19,y+
 0046 2991              ld R18,y+
 0048 1991              ld R17,y+
 004A 0991              ld R16,y+
 004C 9990              ld R9,y+
 004E 8990              ld R8,y+
 0050 7990              ld R7,y+
 0052 6990              ld R6,y+
 0054 5990              ld R5,y+
 0056 4990              ld R4,y+
 0058 3990              ld R3,y+
 005A 2990              ld R2,y+
 005C 1990              ld R1,y+
 005E 0990              ld R0,y+
 0060 1895              reti
 0062                   .dbsym l b 1 c
 0062                   .dbsym l a 1 c
 0062                   .dbend
                        .area vector(rom, abs)
                        .org 12
 000C 31C0              rjmp _ISR_tmr1_ovf_handler
                        .area text(rom, con, rel)
 0062                   .dbfile f:\MYDOCU~1\AVR\led\代码\led.c
 0062                   .dbfunc e ISR_tmr1_ovf_handler _ISR_tmr1_ovf_handler fV
                        .even
 0062           _ISR_tmr1_ovf_handler::
 0062 8A93              st -y,R24
 0064 8FB7              in R24,0x3f
 0066 8A93              st -y,R24
 0068                   .dbline -1
 0068                   .dbline 52
 0068           ; /*
 0068           ; //this way is easier on the stack
 0068           ;       for (a = 1; a; a++)
 0068           ;               for (b = 1; b; b++)
 0068           ;                       ;
 0068           ; */                    
 0068           ; }
 0068           ; 
 0068           ; #pragma interrupt_handler ISR_tmr1_ovf_handler:7
 0068           ; void ISR_tmr1_ovf_handler()
 0068           ; {
 0068                   .dbline 54
 0068           ; //     PORTB = 0x0f; //sanity check
 0068           ;        tmrRollFlag = 1;
 0068 81E0              ldi R24,1
 006A 80930000          sts _tmrRollFlag,R24
 006E                   .dbline -2
 006E           L2:
 006E                   .dbline 0 ; func end
 006E 8991              ld R24,y+
 0070 8FBF              out 0x3f,R24
 0072 8991              ld R24,y+
 0074 1895              reti
 0076                   .dbend
 0076                   .dbfunc e delay _delay fV
 0076           ;              i -> R20,R21
 0076           ;              n -> R16
                        .even
 0076           _delay::
 0076 4A93              st -y,R20
 0078 5A93              st -y,R21
 007A                   .dbline -1
 007A                   .dbline 58
 007A           ; }
 007A           ; 
 007A           ; void delay(unsigned char n)
 007A           ; {
 007A                   .dbline 61
 007A           ;       int i;
 007A           ;       
 007A           ;       for (i = 0; i < n; i++) {
 007A 4427              clr R20
 007C 5527              clr R21
 007E 09C0              rjmp L7
 0080           L4:
 0080                   .dbline 61
 0080                   .dbline 62
 0080           ;               tmrRollFlag = 0;
 0080 2224              clr R2
 0082 20920000          sts _tmrRollFlag,R2
 0086           L8:
 0086                   .dbline 63
 0086           ;               while (!tmrRollFlag); //wait for IRQ
 0086           L9:
 0086                   .dbline 63
 0086 20900000          lds R2,_tmrRollFlag
 008A 2220              tst R2
 008C E1F3              breq L8
 008E           X0:
 008E                   .dbline 64
 008E           ;       }
 008E           L5:
 008E                   .dbline 61
 008E 4F5F              subi R20,255  ; offset = 1
 0090 5F4F              sbci R21,255
 0092           L7:
 0092                   .dbline 61
 0092 202E              mov R2,R16
 0094 3324              clr R3
 0096 4215              cp R20,R2
 0098 5305              cpc R21,R3
 009A 94F3              brlt L4
 009C           X1:
 009C                   .dbline -2
 009C           L3:
 009C                   .dbline 0 ; func end
 009C 5991              ld R21,y+
 009E 4991              ld R20,y+
 00A0 0895              ret
 00A2                   .dbsym r i 20 I
 00A2                   .dbsym r n 16 c
 00A2                   .dbend
 00A2                   .dbfunc e delay2 _delay2 fV
 00A2           ;              a -> R20
 00A2           ;              b -> R22
 00A2           ;              c -> R10
 00A2           ;              n -> R16
                        .even
 00A2           _delay2::
 00A2 00D0              rcall push_xgsetF00C
 00A4                   .dbline -1
 00A4                   .dbline 77
 00A4           ; 
 00A4           ; }
 00A4           ; 
 00A4           ; #ifdef FIXED_DELAY
 00A4           ; void delay()
 00A4           ; {
 00A4           ;       tmrRollFlag = 0;
 00A4           ;       while (!tmrRollFlag); //wait for IRQ
 00A4           ; }
 00A4           ; #endif
 00A4           ; 
 00A4           ; void delay2(unsigned char n)
 00A4           ; {
 00A4                   .dbline 80
 00A4           ;       unsigned char a, b, c;
 00A4           ; 
 00A4           ;       for (a = 1; a; a++)
 00A4 41E0              ldi R20,1
 00A6 0CC0              rjmp L15
 00A8           L12:
 00A8                   .dbline 81
 00A8           ;               for (b = 1; b; b++)
 00A8 61E0              ldi R22,1
 00AA 07C0              rjmp L19
 00AC           L16:
 00AC                   .dbline 82
 00AC           ;                       for (c = 1; c<n; c++)
 00AC AA24              clr R10
 00AE A394              inc R10
 00B0 01C0              rjmp L23
 00B2           L20:

⌨️ 快捷键说明

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