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

📄 counter.lis

📁 本文给出了频率计的一般设计方法及软件的如何编码
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module counter.c
                        .area data(ram, con, rel)
 0000           _digits::
 0000                   .blkb 2
                        .area idata
 0000 3F06              .byte 63,6
                        .area data(ram, con, rel)
 0002                   .blkb 2
                        .area idata
 0002 5B4F              .byte 91,'O
                        .area data(ram, con, rel)
 0004                   .blkb 2
                        .area idata
 0004 666D              .byte 'f,'m
                        .area data(ram, con, rel)
 0006                   .blkb 2
                        .area idata
 0006 7D07              .byte 125,7
                        .area data(ram, con, rel)
 0008                   .blkb 2
                        .area idata
 0008 7F6F              .byte 127,'o
                        .area data(ram, con, rel)
 000A                   .blkb 2
                        .area idata
 000A 0140              .byte 1,64
                        .area data(ram, con, rel)
 000C                   .blkb 1
                        .area idata
 000C 08                .byte 8
                        .area data(ram, con, rel)
 000D                   .dbfile D:\频率计\counter.c
 000D                   .dbsym e digits _digits A[13:13]c
 000D           _active_led::
 000D                   .blkb 1
                        .area idata
 000D 00                .byte 0
                        .area data(ram, con, rel)
 000E                   .dbfile D:\频率计\counter.c
 000E                   .dbsym e active_led _active_led c
 000E           _led_value::
 000E                   .blkb 4
                        .area idata
 000E 00000000          .word 0,0
                        .area data(ram, con, rel)
 0012                   .dbfile D:\频率计\counter.c
 0012                   .dbsym e led_value _led_value l
 0012           _decimal_point::
 0012                   .blkb 1
                        .area idata
 0012 00                .byte 0
                        .area data(ram, con, rel)
 0013                   .dbfile D:\频率计\counter.c
 0013                   .dbsym e decimal_point _decimal_point c
 0013           _mode_setting::
 0013                   .blkb 1
                        .area idata
 0013 00                .byte 0
                        .area data(ram, con, rel)
 0014                   .dbfile D:\频率计\counter.c
 0014                   .dbsym e mode_setting _mode_setting c
                        .area vector(rom, abs)
                        .org 12
 000C 00C0              rjmp _timer0_ovf_isr
                        .area data(ram, con, rel)
 0014                   .dbfile D:\频率计\counter.c
                        .area text(rom, con, rel)
 0000                   .dbfile D:\频率计\counter.c
 0000                   .dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
 0000           ;              a -> R22
 0000           ;              b -> R20
                        .even
 0000           _timer0_ovf_isr::
 0000 2A92              st -y,R2
 0002 3A92              st -y,R3
 0004 4A92              st -y,R4
 0006 5A92              st -y,R5
 0008 0A93              st -y,R16
 000A 1A93              st -y,R17
 000C 2A93              st -y,R18
 000E 3A93              st -y,R19
 0010 8A93              st -y,R24
 0012 9A93              st -y,R25
 0014 AA93              st -y,R26
 0016 BA93              st -y,R27
 0018 EA93              st -y,R30
 001A FA93              st -y,R31
 001C 2FB6              in R2,0x3f
 001E 2A92              st -y,R2
 0020 00D0              rcall push_gset2
 0022                   .dbline -1
 0022                   .dbline 122
 0022           ; 
 0022           ; 
 0022           ; /*
 0022           ;   Jesper Hansen <jesperh@telia.com>
 0022           ; 
 0022           ;   This program is free software; you can redistribute it and/or
 0022           ;   modify it under the terms of the GNU General Public License
 0022           ;   as published by the Free Software Foundation; either version 2
 0022           ;   of the License, or (at your option) any later version.
 0022           ; 
 0022           ;   This program is distributed in the hope that it will be useful,
 0022           ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
 0022           ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 0022           ;   GNU General Public License for more details.
 0022           ; 
 0022           ;   You should have received a copy of the GNU General Public License
 0022           ;   along with this program; if not, write to the Free Software Foundation, 
 0022           ;   Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 0022           ; 
 0022           ; 
 0022           ; 
 0022           ;     Project: CounterMeasures
 0022           ; 
 0022           ; 
 0022           ;     40 MHz Frequency Counter
 0022           ;     ------------------------
 0022           ;     
 0022           ;     CPU :       At90S2313
 0022           ; 
 0022           ;     Date:       2001-03-02
 0022           ; 
 0022           ;     Author :    Jesper Hansen
 0022           ; 
 0022           ; 
 0022           ; 
 0022           ; 
 0022           ; 
 0022           ;     Current consumption about 40-45 mA.
 0022           ; 
 0022           ;     Measures to > 50 MHz
 0022           ;     
 0022           ; 
 0022           ; */
 0022           ; 
 0022           ; 
 0022           ; #include <io2313v.h>
 0022           ; #include <macros.h>
 0022           ; #include "counter.h"
 0022           ; 
 0022           ; 
 0022           ; // PORT D bits
 0022           ; 
 0022           ; // al counter control bits active low
 0022           ; 
 0022           ; #define CLEAR   PD6
 0022           ; #define OE_H    PD5
 0022           ; #define OE_L    PD4
 0022           ; 
 0022           ; // PD3..0 is lower data bus
 0022           ; 
 0022           ; 
 0022           ; // PORT B
 0022           ; 
 0022           ; // PB7..4 is high data bus
 0022           ; // PB3 is OC1 output 
 0022           ; // PB2..0 is 74HC138 select bits for display common
 0022           ; 
 0022           ; 
 0022           ; 
 0022           ; // constants/macros 
 0022           ; #define F_CPU        4000000                    // 4MHz processor 
 0022           ; #define CYCLES_PER_US ((F_CPU+500000)/1000000)  // cpu cycles per microsecond 
 0022           ; 
 0022           ; 
 0022           ; // display data
 0022           ; 
 0022           ; #define SEG_a   0x01
 0022           ; #define SEG_b   0x02
 0022           ; #define SEG_c   0x04
 0022           ; #define SEG_d   0x08
 0022           ; #define SEG_e   0x10
 0022           ; #define SEG_f   0x20
 0022           ; #define SEG_g   0x40
 0022           ; #define SEG_dot 0x80
 0022           ; 
 0022           ; 
 0022           ; unsigned char digits[] = {
 0022           ;     (SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f),            // 0
 0022           ;     (SEG_b|SEG_c),                                                    // 1
 0022           ;     (SEG_a|SEG_b|SEG_d|SEG_e|SEG_g),                  // 2
 0022           ;     (SEG_a|SEG_b|SEG_c|SEG_d|SEG_g),                  // 3
 0022           ;     (SEG_b|SEG_c|SEG_c|SEG_f|SEG_g),                  // 4
 0022           ;     (SEG_a|SEG_c|SEG_d|SEG_f|SEG_g),                  // 5
 0022           ;     (SEG_a|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g),            // 6
 0022           ;     (SEG_a|SEG_b|SEG_c),                                              // 7
 0022           ;     (SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g),    // 8
 0022           ;     (SEG_a|SEG_b|SEG_c|SEG_d|SEG_f|SEG_g),            // 9
 0022           ;     
 0022           ;     (SEG_a),                                          // mode 0 indicator     (Hz)
 0022           ;     (SEG_g),                                          // mode 1 indicator (kHz)
 0022           ;     (SEG_d),                                          // mode 2 indicator (MHz)
 0022           ; };
 0022           ; 
 0022           ; 
 0022           ; /****************************************************************************/
 0022           ; 
 0022           ; 
 0022           ; // timer 0 interrupt handles multiplex and refresh of the displays
 0022           ; // timer is clocked at 62500 Hz
 0022           ; 
 0022           ; #define TI0_L       (256-125)       // 500 Hz -> 2 mS
 0022           ; 
 0022           ; volatile unsigned char  active_led = 0;
 0022           ; 
 0022           ; volatile unsigned long  led_value = 0;  // four BCD nibbles
 0022           ; volatile unsigned char  decimal_point = 0;
 0022           ; volatile unsigned char  mode_setting = 0;
 0022           ; 
 0022           ; 
 0022           ; #pragma interrupt_handler timer0_ovf_isr:7  
 0022           ; void timer0_ovf_isr(void) //timer 0 overflow
 0022           ; {
 0022                   .dbline 126
 0022           ;     unsigned char a,b;
 0022           ; 
 0022           ;     // reload timer
 0022           ;     outp(TI0_L, TCNT0);
 0022 83E8              ldi R24,131
 0024 82BF              out 0x32,R24
 0026                   .dbline 129
 0026           ; 
 0026           ;     // all displays off by setting all commons high
 0026           ;     outp(inp(PORTB) | 0x07, PORTB);
 0026 88B3              in R24,0x18
 0028 8760              ori R24,7
 002A 88BB              out 0x18,R24
 002C                   .dbline 131
 002C           ;     
 002C           ;     if (active_led == 5)
 002C 80910D00          lds R24,_active_led
 0030 8530              cpi R24,5
 0032 49F4              brne L2
 0034                   .dbline 132
 0034           ;     {
 0034                   .dbline 133
 0034           ;         b = digits[10 + mode_setting];
 0034 80E0              ldi R24,<_digits+10
 0036 90E0              ldi R25,>_digits+10
 0038 E0911300          lds R30,_mode_setting
 003C FF27              clr R31
 003E E80F              add R30,R24
 0040 F91F              adc R31,R25
 0042 4081              ldd R20,z+0
 0044                   .dbline 134
 0044           ;     }
 0044 2CC0              rjmp L3
 0046           L2:
 0046                   .dbline 136
 0046           ;     else
 0046           ;     {
 0046                   .dbline 137
 0046           ;         a = led_value >> (( 4 - active_led ) * 4);
 0046 20900D00          lds R2,_active_led
 004A 3324              clr R3
 004C 84E0              ldi R24,4
 004E 90E0              ldi R25,0
 0050 8219              sub R24,R2
 0052 9309              sbc R25,R3
 0054 880F              lsl R24
 0056 991F              rol R25
 0058 880F              lsl R24
 005A 991F              rol R25
 005C 40901000          lds R4,_led_value+2
 0060 50901100          lds R5,_led_value+2+1
 0064 20900E00          lds R2,_led_value
 0068 30900F00          lds R3,_led_value+1
 006C 8A93              st -y,R24
 006E 022D              mov R16,R2
 0070 132D              mov R17,R3
 0072 242D              mov R18,R4
 0074 352D              mov R19,R5
 0076 00D0              rcall lsr32
 0078 602F              mov R22,R16
 007A                   .dbline 139
 007A           ;     
 007A           ;         b = digits[a & 0x0f];
 007A 80E0              ldi R24,<_digits
 007C 90E0              ldi R25,>_digits
 007E E62F              mov R30,R22
 0080 FF27              clr R31
 0082 EF70              andi R30,15
 0084 F070              andi R31,0
 0086 E80F              add R30,R24
 0088 F91F              adc R31,R25
 008A 4081              ldd R20,z+0
 008C                   .dbline 141
 008C           ;     
 008C           ;         if (decimal_point == (4 - active_led) )
 008C 20900D00          lds R2,_active_led
 0090 84E0              ldi R24,4
 0092 8219              sub R24,R2
 0094 20901200          lds R2,_decimal_point
 0098 2816              cp R2,R24
 009A 09F4              brne L5
 009C                   .dbline 142
 009C           ;             b |= SEG_dot;
 009C 4068              ori R20,128
 009E           L5:
 009E                   .dbline 143
 009E           ;     }
 009E           L3:
 009E                   .dbline 145
 009E           ; 
 009E           ;     a = b & 0xf0;   // hi part
 009E 642F              mov R22,R20
 00A0 607F              andi R22,240
 00A2                   .dbline 146
 00A2           ;     b = b & 0x0f;   // lo part
 00A2 4F70              andi R20,15
 00A4                   .dbline 149
 00A4           ; 
 00A4           ;     // set digit data on port
 00A4           ;     outp( (inp(PORTB) & 0x0f) | a, PORTB);  // high part
 00A4 88B3              in R24,0x18
 00A6 8F70              andi R24,15
 00A8 862B              or R24,R22
 00AA 88BB              out 0x18,R24
 00AC                   .dbline 150
 00AC           ;     outp( (inp(PORTD) & 0xf0) | b, PORTD);  // low part
 00AC 82B3              in R24,0x12
 00AE 807F              andi R24,240
 00B0 842B              or R24,R20
 00B2 82BB              out 0x12,R24
 00B4                   .dbline 153
 00B4           ; 
 00B4           ;     // set common             
 00B4           ;     outp( (inp(PORTB) & 0xf8) | active_led, PORTB);
 00B4 20900D00          lds R2,_active_led
 00B8 88B3              in R24,0x18
 00BA 887F              andi R24,248
 00BC 8229              or R24,R2
 00BE 88BB              out 0x18,R24
 00C0                   .dbline 155
 00C0           ; 
 00C0           ;     active_led = (active_led+1) % 6;
 00C0 16E0              ldi R17,6
 00C2 00910D00          lds R16,_active_led
 00C6 0F5F              subi R16,255    ; addi 1
 00C8 00D0              rcall mod8u
 00CA 00930D00          sts _active_led,R16
 00CE                   .dbline -2
 00CE                   .dbline 156
 00CE           ; }
 00CE           L1:
 00CE 00D0              rcall pop_gset2
 00D0 2990              ld R2,y+
 00D2 2FBE              out 0x3f,R2
 00D4 F991              ld R31,y+
 00D6 E991              ld R30,y+
 00D8 B991              ld R27,y+
 00DA A991              ld R26,y+
 00DC 9991              ld R25,y+
 00DE 8991              ld R24,y+
 00E0 3991              ld R19,y+
 00E2 2991              ld R18,y+
 00E4 1991              ld R17,y+
 00E6 0991              ld R16,y+
 00E8 5990              ld R5,y+
 00EA 4990              ld R4,y+
 00EC 3990              ld R3,y+
 00EE 2990              ld R2,y+
 00F0                   .dbline 0 ; func end
 00F0 1895              reti
 00F2                   .dbsym r a 22 c
 00F2                   .dbsym r b 20 c
 00F2                   .dbend
 00F2                   .dbfunc e delay _delay fV
 00F2           ;    delay_loops -> R20,R21
 00F2           ;              i -> R22,R23
 00F2           ;             us -> R20,R21
                        .even
 00F2           _delay::
 00F2 00D0              rcall push_gset2
 00F4 402F              mov R20,R16
 00F6 512F              mov R21,R17
 00F8                   .dbline -1
 00F8                   .dbline 168
 00F8           ; 
 00F8           ; 
 00F8           ; 
 00F8           ; 

⌨️ 快捷键说明

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