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

📄 app.lis

📁 AVR单片机C语言程序设计实例精粹
💻 LIS
字号:
                        .module app.c
                        .area text(rom, con, rel)
 0000                   .dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\交通灯控制系统设计\app.c
 0000                   .dbfunc e Hardware_Init _Hardware_Init fV
                        .even
 0000           _Hardware_Init::
 0000                   .dbline -1
 0000                   .dbline 20
 0000           ; //***************************************************************
 0000           ; // File Name : Gpio.c
 0000           ; // Author    : Steaven
 0000           ; // Created   : 2008-06-09
 0000           ; // Modified  : 
 0000           ; // Revision  : V0.0
 0000           ; //***************************************************************
 0000           ; 
 0000           ; #include "iom16v.h" 
 0000           ; #include "DataType.h"
 0000           ; #include "app.h"
 0000           ; 
 0000           ; //***************************************************************
 0000           ; // Function    : Hardware_Init
 0000           ; // Input       : none
 0000           ; // Output      : none
 0000           ; // Description : ATmega16 Hardware Initialization
 0000           ; //***************************************************************
 0000           ; void Hardware_Init(void)
 0000           ; {
 0000                   .dbline 21
 0000           ;     Gpio_Init();
 0000 03D0              xcall _Gpio_Init
 0002                   .dbline 22
 0002           ;     Timer0_Init();
 0002 0DD0              xcall _Timer0_Init
 0004                   .dbline 23
 0004           ;     Timer1_Init();
 0004 19D0              xcall _Timer1_Init
 0006                   .dbline 24
 0006           ;     Interrupt_Init();
 0006                   .dbline -2
 0006                   .dbline 25
 0006           ; }
 0006           L1:
 0006                   .dbline 0 ; func end
 0006 2AC0              xjmp _Interrupt_Init
 0008                   .dbend
 0008                   .dbfunc e Gpio_Init _Gpio_Init fV
                        .even
 0008           _Gpio_Init::
 0008                   .dbline -1
 0008                   .dbline 34
 0008           ; 
 0008           ; //***************************************************************
 0008           ; // Function    : Gpio_Init
 0008           ; // Input       : none
 0008           ; // Output      : none
 0008           ; // Description : ATmega16 GPIO Initialization
 0008           ; //***************************************************************
 0008           ; void Gpio_Init(void)
 0008           ; {
 0008                   .dbline 35
 0008           ;        DDRA  = 0xFF;
 0008 8FEF              ldi R24,255
 000A 8ABB              out 0x1a,R24
 000C                   .dbline 36
 000C           ;     PORTA = 0x00;
 000C 2224              clr R2
 000E 2BBA              out 0x1b,R2
 0010                   .dbline 37
 0010           ;     DDRB  = 0xFF;
 0010 87BB              out 0x17,R24
 0012                   .dbline 38
 0012           ;     PORTB = 0x00;
 0012 28BA              out 0x18,R2
 0014                   .dbline 39
 0014           ;     DDRC  = 0xFF;
 0014 84BB              out 0x14,R24
 0016                   .dbline 40
 0016           ;     PORTC = 0x00;
 0016 25BA              out 0x15,R2
 0018                   .dbline 41
 0018           ;     DDRD  = 0xFF;
 0018 81BB              out 0x11,R24
 001A                   .dbline 42
 001A           ;     PORTD = 0x00;
 001A 22BA              out 0x12,R2
 001C                   .dbline -2
 001C                   .dbline 44
 001C           ;        //while(1) {;}
 001C           ; }
 001C           L2:
 001C                   .dbline 0 ; func end
 001C 0895              ret
 001E                   .dbend
 001E                   .dbfunc e Timer0_Init _Timer0_Init fV
                        .even
 001E           _Timer0_Init::
 001E                   .dbline -1
 001E                   .dbline 53
 001E           ; 
 001E           ; //***************************************************************
 001E           ; // Function    : Timer0_Init
 001E           ; // Input       : none
 001E           ; // Output      : none
 001E           ; // Description : ATmega16 Timer0 Initialization,10ms Interval
 001E           ; //***************************************************************
 001E           ; void Timer0_Init(void)
 001E           ; {
 001E                   .dbline 54
 001E           ;       TCCR0 = 0x0D;   //1024 division,8M/1024,CTC Mode
 001E 8DE0              ldi R24,13
 0020 83BF              out 0x33,R24
 0022                   .dbline 55
 0022           ;       TCNT0 = 0x00;   //Clear Counter
 0022 2224              clr R2
 0024 22BE              out 0x32,R2
 0026                   .dbline 56
 0026           ;       OCR0  = 78;     //78 * 1024/8M = 10ms 
 0026 8EE4              ldi R24,78
 0028 8CBF              out 0x3c,R24
 002A                   .dbline 57
 002A           ;       TIMSK |= 0x02;  //Enable OCIE0
 002A 89B7              in R24,0x39
 002C 8260              ori R24,2
 002E 89BF              out 0x39,R24
 0030                   .dbline 58
 0030           ;       TIFR  |= 0x02;  //Clear OCIF0
 0030 88B7              in R24,0x38
 0032 8260              ori R24,2
 0034 88BF              out 0x38,R24
 0036                   .dbline -2
 0036                   .dbline 59
 0036           ; }
 0036           L3:
 0036                   .dbline 0 ; func end
 0036 0895              ret
 0038                   .dbend
 0038                   .dbfunc e Timer1_Init _Timer1_Init fV
                        .even
 0038           _Timer1_Init::
 0038                   .dbline -1
 0038                   .dbline 68
 0038           ; 
 0038           ; //***************************************************************
 0038           ; // Function    : Timer1_Init
 0038           ; // Input       : none
 0038           ; // Output      : none
 0038           ; // Description : ATmega16 Timer1 Initialization,1s Interval
 0038           ; //***************************************************************
 0038           ; void Timer1_Init(void)
 0038           ; {
 0038                   .dbline 69
 0038           ;       TCCR1A = 0x00;  //WGM1[3:0]=0100,OCR1A
 0038 2224              clr R2
 003A 2FBC              out 0x2f,R2
 003C                   .dbline 70
 003C           ;    TCCR1B = 0x0D;  //1024 division,8M/1024,CTC Mode   
 003C 8DE0              ldi R24,13
 003E 8EBD              out 0x2e,R24
 0040                   .dbline 71
 0040           ;    TCNT1  = 0x00;  //Clear Counter
 0040 3324              clr R3
 0042 3DBC              out 0x2d,R3
 0044 2CBC              out 0x2c,R2
 0046                   .dbline 72
 0046           ;       OCR1A  = 7813;  //7813 * 1024/8M = 1s 
 0046 85E8              ldi R24,7813
 0048 9EE1              ldi R25,30
 004A 9BBD              out 0x2b,R25
 004C 8ABD              out 0x2a,R24
 004E                   .dbline 73
 004E           ;       TIMSK |= 0x10;  //Enable OCIE1A
 004E 89B7              in R24,0x39
 0050 8061              ori R24,16
 0052 89BF              out 0x39,R24
 0054                   .dbline 74
 0054           ;       TIFR  |= 0x10;  //Clear OCIF1A
 0054 88B7              in R24,0x38
 0056 8061              ori R24,16
 0058 88BF              out 0x38,R24
 005A                   .dbline -2
 005A                   .dbline 75
 005A           ; }
 005A           L4:
 005A                   .dbline 0 ; func end
 005A 0895              ret
 005C                   .dbend
 005C                   .dbfunc e Interrupt_Init _Interrupt_Init fV
                        .even
 005C           _Interrupt_Init::
 005C                   .dbline -1
 005C                   .dbline 84
 005C           ; 
 005C           ; //***************************************************************
 005C           ; // Function    : Interrupt_Init
 005C           ; // Input       : none
 005C           ; // Output      : none
 005C           ; // Description : ATmega16 Interrupt Initialization
 005C           ; //***************************************************************
 005C           ; void Interrupt_Init(void)
 005C           ; {
 005C                   .dbline 85
 005C           ;       SREG |= 0x80;   //Enable Global Interrupt
 005C 7894              bset 7
 005E                   .dbline -2
 005E                   .dbline 86
 005E           ; }
 005E           L5:
 005E                   .dbline 0 ; func end
 005E 0895              ret
 0060                   .dbend
 0060                   .dbfunc e LED_ON_OFF _LED_ON_OFF fV
 0060           ;         Action -> R22
 0060           ;          Index -> R20
                        .even
 0060           _LED_ON_OFF::
 0060 0E940000          xcall push_gset2
 0064 622F              mov R22,R18
 0066 402F              mov R20,R16
 0068                   .dbline -1
 0068                   .dbline 95
 0068           ; 
 0068           ; //***************************************************************
 0068           ; // Function    : Interrupt_Init
 0068           ; // Input       : none
 0068           ; // Output      : none
 0068           ; // Description : ATmega16 Interrupt Initialization
 0068           ; //***************************************************************
 0068           ; void LED_ON_OFF(INT8U Index,INT8U Action)
 0068           ; {
 0068                   .dbline 96
 0068           ;     if(Action == cLED_ON)
 0068 6130              cpi R22,1
 006A 41F4              brne L7
 006C                   .dbline 97
 006C           ;     {
 006C                   .dbline 98
 006C           ;         PORTC |= (1 << Index);
 006C 01E0              ldi R16,1
 006E 142F              mov R17,R20
 0070 0E940000          xcall lsl8
 0074 25B2              in R2,0x15
 0076 202A              or R2,R16
 0078 25BA              out 0x15,R2
 007A                   .dbline 99
 007A           ;     }
 007A 09C0              xjmp L8
 007C           L7:
 007C                   .dbline 101
 007C                   .dbline 102
 007C 01E0              ldi R16,1
 007E 142F              mov R17,R20
 0080 0E940000          xcall lsl8
 0084 202E              mov R2,R16
 0086 2094              com R2
 0088 35B2              in R3,0x15
 008A 3220              and R3,R2
 008C 35BA              out 0x15,R3
 008E                   .dbline 103
 008E           L8:
 008E                   .dbline -2
 008E                   .dbline 104
 008E           ;     else
 008E           ;     {
 008E           ;         PORTC &= ~(1 << Index);
 008E           ;     }
 008E           ; }
 008E           L6:
 008E 0E940000          xcall pop_gset2
 0092                   .dbline 0 ; func end
 0092 0895              ret
 0094                   .dbsym r Action 22 c
 0094                   .dbsym r Index 20 c
 0094                   .dbend
 0094                   .dbfunc e INT2BCD _INT2BCD fV
 0094           ;          pdata -> R20,R21
 0094           ;           Data -> R22
                        .even
 0094           _INT2BCD::
 0094 0E940000          xcall push_gset2
 0098 A901              movw R20,R18
 009A 602F              mov R22,R16
 009C                   .dbline -1
 009C                   .dbline 114
 009C           ; 
 009C           ; //***************************************************************
 009C           ; // Function    : Interrupt_Init
 009C           ; // Input       : Data - Integer Type Data
 009C           ; //               pdata - Pointer to BCD Data Array
 009C           ; // Output      : none
 009C           ; // Description : Convert Integer Data to BCD Type Data
 009C           ; //***************************************************************
 009C           ; void INT2BCD(INT8U Data,INT8U *pdata)
 009C           ; {
 009C                   .dbline 115
 009C           ;     *pdata++ = Data % 10;
 009C 1AE0              ldi R17,10
 009E 062F              mov R16,R22
 00A0 0E940000          xcall mod8u
 00A4 FA01              movw R30,R20
 00A6 0193              st Z+,R16
 00A8 AF01              movw R20,R30
 00AA                   .dbline 116
 00AA           ;     *pdata   = Data / 10;
 00AA 1AE0              ldi R17,10
 00AC 062F              mov R16,R22
 00AE 0E940000          xcall div8u
 00B2 FA01              movw R30,R20
 00B4 0083              std z+0,R16
 00B6                   .dbline -2
 00B6                   .dbline 117
 00B6           ; }
 00B6           L9:
 00B6 0E940000          xcall pop_gset2
 00BA                   .dbline 0 ; func end
 00BA 0895              ret
 00BC                   .dbsym r pdata 20 pc
 00BC                   .dbsym r Data 22 c
 00BC                   .dbend
 00BC                   .dbfunc e DataConvert _DataConvert fc
 00BC           ;           Data -> R16
                        .even
 00BC           _DataConvert::
 00BC                   .dbline -1
 00BC                   .dbline 120
 00BC           ; 
 00BC           ; INT8U DataConvert(INT8U Data)
 00BC           ; {
 00BC                   .dbline 121
 00BC           ;     if(Data <= 9)
 00BC 89E0              ldi R24,9
 00BE 8017              cp R24,R16
 00C0 40F0              brlo L11
 00C2                   .dbline 122
 00C2           ;               {
 00C2                   .dbline 123
 00C2           ;                   return(SegTable[Data]);
 00C2 80E0              ldi R24,<_SegTable
 00C4 90E0              ldi R25,>_SegTable
 00C6 E02F              mov R30,R16
 00C8 FF27              clr R31
 00CA E80F              add R30,R24
 00CC F91F              adc R31,R25
 00CE 0491              lpm R16,Z
 00D0 01C0              xjmp L10
 00D2           L11:
 00D2                   .dbline 125
 00D2           ;               }
 00D2           ;               return(0);
 00D2 0027              clr R16
 00D4                   .dbline -2
 00D4           L10:
 00D4                   .dbline 0 ; func end
 00D4 0895              ret
 00D6                   .dbsym r Data 16 c
 00D6                   .dbend

⌨️ 快捷键说明

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