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

📄 频率计.lst

📁 使用单片机实现的对信号源的频率测试。准确精确度好!
💻 LST
📖 第 1 页 / 共 2 页
字号:
__start:
__text_start:
    0033 E5CF      LDI	R28,0x5F
    0034 E0D4      LDI	R29,4
    0035 BFCD      OUT	0x3D,R28
    0036 BFDE      OUT	0x3E,R29
    0037 51C0      SUBI	R28,0x10
    0038 40D0      SBCI	R29,0
    0039 EA0A      LDI	R16,0xAA
    003A 8308      STD	Y+0,R16
    003B 2400      CLR	R0
    003C E7E2      LDI	R30,0x72
    003D E0F0      LDI	R31,0
    003E E010      LDI	R17,0
    003F 37E8      CPI	R30,0x78
    0040 07F1      CPC	R31,R17
    0041 F011      BEQ	0x0044
    0042 9201      ST	R0,Z+
    0043 CFFB      RJMP	0x003F
    0044 8300      STD	Z+0,R16
    0045 E5E4      LDI	R30,0x54
    0046 E0F0      LDI	R31,0
    0047 E6A0      LDI	R26,0x60
    0048 E0B0      LDI	R27,0
    0049 E010      LDI	R17,0
    004A 36E6      CPI	R30,0x66
    004B 07F1      CPC	R31,R17
    004C F021      BEQ	0x0051
    004D 95C8      LPM
    004E 9631      ADIW	R30,1
    004F 920D      ST	R0,X+
    0050 CFF9      RJMP	0x004A
    0051 940E01AA  CALL	_main
_exit:
    0053 CFFF      RJMP	_exit
FILE: D:\avr\+++精华+++\频率计\delay.h
(0001) /*-----------------------------------------------------------------------
(0002) 延时函数
(0003) 编译器:ICC-AVR v6.31A 
(0004) 目标芯片 : M16
(0005) 时钟: 1.0000Mhz
(0006) -----------------------------------------------------------------------*/
(0007) #ifndef __delay_h
(0008) #define __delay_h
(0009) void delay_nus(unsigned int n);
(0010) void delay_nms(unsigned int n);
(0011) void delay_1us(void);
(0012) void delay_1ms(void) ; 
(0013) 
(0014) void delay_1us(void)                 //1us延时函数
(0015)   {
(0016)    asm("nop");
_delay_1us:
    0054 0000      NOP
    0055 9508      RET
_delay_nus:
  i                    --> R20
  n                    --> R22
    0056 940E01E5  CALL	push_gset2
    0058 01B8      MOVW	R22,R16
(0017)   }
(0018) 
(0019) void delay_nus(unsigned int n)       //N us延时函数
(0020)   {
(0021)    unsigned int i=0;
    0059 2744      CLR	R20
    005A 2755      CLR	R21
(0022)    for (i=0;i<n;i++)
    005B C003      RJMP	0x005F
(0023)    delay_1us();
    005C DFF7      RCALL	_delay_1us
    005D 5F4F      SUBI	R20,0xFF
    005E 4F5F      SBCI	R21,0xFF
    005F 1746      CP	R20,R22
    0060 0757      CPC	R21,R23
    0061 F3D0      BCS	0x005C
    0062 940E01D9  CALL	pop_gset2
    0064 9508      RET
(0024)   }
(0025)   
(0026) void delay_1ms(void)                 //1ms延时函数
(0027)   {
(0028)    unsigned int i;
(0029)    for (i=0;i<1140;i++);
_delay_1ms:
  i                    --> R16
    0065 2700      CLR	R16
    0066 2711      CLR	R17
    0067 C002      RJMP	0x006A
    0068 5F0F      SUBI	R16,0xFF
    0069 4F1F      SBCI	R17,0xFF
    006A 3704      CPI	R16,0x74
    006B E0E4      LDI	R30,4
    006C 071E      CPC	R17,R30
    006D F3D0      BCS	0x0068
    006E 9508      RET
_delay_nms:
  i                    --> R20
  n                    --> R22
    006F 940E01E5  CALL	push_gset2
    0071 01B8      MOVW	R22,R16
(0030)   }
(0031)   
(0032) void delay_nms(unsigned int n)       //N ms延时函数
(0033)   {
(0034)    unsigned int i=0;
    0072 2744      CLR	R20
    0073 2755      CLR	R21
(0035)    for (i=0;i<n;i++)
    0074 C003      RJMP	0x0078
(0036)    delay_1ms();
    0075 DFEF      RCALL	_delay_1ms
    0076 5F4F      SUBI	R20,0xFF
    0077 4F5F      SBCI	R21,0xFF
    0078 1746      CP	R20,R22
    0079 0757      CPC	R21,R23
    007A F3D0      BCS	0x0075
    007B 940E01D9  CALL	pop_gset2
    007D 9508      RET
FILE: D:\avr\+++精华+++\频率计\1602.h
(0001) 
(0002) /* 用法:
(0003)    LCD_init();
(0004)    LCD_write_string(列,行,"字符串");
(0005)    LCD_write_char(列,行,'字符'); 
(0006)  ---------------------------------------------------------------
(0007) 下面是AVR与LCD连接信息
(0008) PA2 ->RS
(0009) PA3 ->EN
(0010) 地  ->RW
(0011) PA4 ->D4
(0012) PA5 ->D5
(0013) PA6 ->D6
(0014) PA7 ->D7
(0015) 要使用本驱动,改变下面配置信息即可
(0016) -----------------------------------------------------------------*/
(0017) #define LCD_EN_PORT    PORTC   //以下2个要设为同一个口
(0018) #define LCD_EN_DDR     DDRC
(0019) #define LCD_RS_PORT    PORTC   //以下2个要设为同一个口
(0020) #define LCD_RS_DDR     DDRC
(0021) #define LCD_DATA_PORT  PORTA   //以下3个要设为同一个口
(0022) #define LCD_DATA_DDR   DDRA    //一定要用高4位
(0023) #define LCD_DATA_PIN   PINA
(0024) #define LCD_RS         (1<<PC6) //0x04   portC6       out
(0025) #define LCD_EN         (1<<PC7) //0x08   portC7       out
(0026) #define LCD_DATA       ((1<<PA4)|(1<<PA5)|(1<<PA6)|(1<<PA7)) //0xf0   portA4/5/6/7 out
(0027) /*--------------------------------------------------------------------------------------------------
(0028) 函数说明
(0029) --------------------------------------------------------------------------------------------------*/
(0030) void LCD_init(void);
(0031) void LCD_en_write(void);
(0032) void LCD_write_command(unsigned  char command) ;
(0033) void LCD_write_data(unsigned char data);
(0034) void LCD_set_xy (unsigned char x, unsigned char y);
(0035) void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s);
(0036) void LCD_write_char(unsigned char X,unsigned char Y,unsigned char data);
(0037) 
(0038) //-----------------------------------------------------------------------------------------
(0039) 
(0040) #include <iom16v.h>
(0041) #include <macros.h>
(0042) #include "delay.h"
(0043) 
(0044) void LCD_init(void)         //液晶初始化
(0045) {
(0046)   LCD_DATA_DDR|=LCD_DATA;   //数据口方向为输出
_LCD_init:
    007E B38A      IN	R24,0x1A
    007F 6F80      ORI	R24,0xF0
    0080 BB8A      OUT	0x1A,R24
(0047)   LCD_EN_DDR|=LCD_EN;       //设置EN方向为输出
    0081 9AA7      SBI	0x14,7
(0048)   LCD_RS_DDR|=LCD_RS;       //设置RS方向为输出
    0082 9AA6      SBI	0x14,6
(0049)   LCD_write_command(0x28); 
    0083 E208      LDI	R16,0x28
    0084 D014      RCALL	_LCD_write_command
(0050)   LCD_en_write();
    0085 D00D      RCALL	_LCD_en_write
(0051)   delay_nus(40);
    0086 E208      LDI	R16,0x28
    0087 E010      LDI	R17,0
    0088 DFCD      RCALL	_delay_nus
(0052)   LCD_write_command(0x28);  //4位显示
    0089 E208      LDI	R16,0x28
    008A D00E      RCALL	_LCD_write_command
(0053)   LCD_write_command(0x0c);  //显示开
    008B E00C      LDI	R16,0xC
    008C D00C      RCALL	_LCD_write_command
(0054)   LCD_write_command(0x01);  //清屏
    008D E001      LDI	R16,1
    008E D00A      RCALL	_LCD_write_command
(0055)   delay_nms(2);
    008F E002      LDI	R16,2
    0090 E010      LDI	R17,0
    0091 DFDD      RCALL	_delay_nms
    0092 9508      RET
(0056) }
(0057) 
(0058) void LCD_en_write(void)  //液晶使能
(0059) {
(0060)   LCD_EN_PORT|=LCD_EN;
_LCD_en_write:
    0093 9AAF      SBI	0x15,7
(0061)   delay_nus(1);
    0094 E001      LDI	R16,1
    0095 E010      LDI	R17,0
    0096 DFBF      RCALL	_delay_nus
(0062)   LCD_EN_PORT&=~LCD_EN;
    0097 98AF      CBI	0x15,7
    0098 9508      RET
_LCD_write_command:
  command              --> R20
    0099 940E01E7  CALL	push_gset1
    009B 2F40      MOV	R20,R16
(0063) }
(0064) 
(0065) void LCD_write_command(unsigned char command) //写指令
(0066) {
(0067)   delay_nus(16);
    009C E100      LDI	R16,0x10
    009D E010      LDI	R17,0
    009E DFB7      RCALL	_delay_nus
(0068)   LCD_RS_PORT&=~LCD_RS;        //RS=0
    009F 98AE      CBI	0x15,6
(0069)   LCD_DATA_PORT&=0X0f;         //清高四位
    00A0 B38B      IN	R24,0x1B
    00A1 708F      ANDI	R24,0xF
    00A2 BB8B      OUT	0x1B,R24
(0070)   LCD_DATA_PORT|=command&0xf0; //写高四位
    00A3 2F84      MOV	R24,R20
    00A4 7F80      ANDI	R24,0xF0
    00A5 B22B      IN	R2,0x1B
    00A6 2A28      OR	R2,R24
    00A7 BA2B      OUT	0x1B,R2
(0071)   LCD_en_write();
    00A8 DFEA      RCALL	_LCD_en_write
(0072)   command=command<<4;          //低四位移到高四位
    00A9 2F84      MOV	R24,R20
    00AA 708F      ANDI	R24,0xF
    00AB 9582      SWAP	R24
    00AC 2F48      MOV	R20,R24
(0073)   LCD_DATA_PORT&=0x0f;         //清高四位
    00AD B38B      IN	R24,0x1B
    00AE 708F      ANDI	R24,0xF
    00AF BB8B      OUT	0x1B,R24
(0074)   LCD_DATA_PORT|=command&0xf0; //写低四位
    00B0 2F84      MOV	R24,R20
    00B1 7F80      ANDI	R24,0xF0
    00B2 B22B      IN	R2,0x1B
    00B3 2A28      OR	R2,R24
    00B4 BA2B      OUT	0x1B,R2
(0075)   LCD_en_write();
    00B5 DFDD      RCALL	_LCD_en_write
    00B6 940E01EA  CALL	pop_gset1
    00B8 9508      RET
_LCD_write_data:
  data                 --> R20
    00B9 940E01E7  CALL	push_gset1
    00BB 2F40      MOV	R20,R16
(0076)   
(0077) }
(0078) 
(0079) void LCD_write_data(unsigned char data) //写数据
(0080) {
(0081)   delay_nus(16);
    00BC E100      LDI	R16,0x10
    00BD E010      LDI	R17,0
    00BE DF97      RCALL	_delay_nus
(0082)   LCD_RS_PORT|=LCD_RS;       //RS=1
    00BF 9AAE      SBI	0x15,6
(0083)   LCD_DATA_PORT&=0X0f;       //清高四位
    00C0 B38B      IN	R24,0x1B
    00C1 708F      ANDI	R24,0xF
    00C2 BB8B      OUT	0x1B,R24
(0084)   LCD_DATA_PORT|=data&0xf0;  //写高四位
    00C3 2F84      MOV	R24,R20
    00C4 7F80      ANDI	R24,0xF0
    00C5 B22B      IN	R2,0x1B
    00C6 2A28      OR	R2,R24
    00C7 BA2B      OUT	0x1B,R2
(0085)   LCD_en_write();
    00C8 DFCA      RCALL	_LCD_en_write
(0086)   data=data<<4;               //低四位移到高四位
    00C9 2F84      MOV	R24,R20
    00CA 708F      ANDI	R24,0xF
    00CB 9582      SWAP	R24
    00CC 2F48      MOV	R20,R24
(0087)   LCD_DATA_PORT&=0X0f;        //清高四位
    00CD B38B      IN	R24,0x1B
    00CE 708F      ANDI	R24,0xF
    00CF BB8B      OUT	0x1B,R24
(0088)   LCD_DATA_PORT|=data&0xf0;   //写低四位
    00D0 2F84      MOV	R24,R20
    00D1 7F80      ANDI	R24,0xF0
    00D2 B22B      IN	R2,0x1B
    00D3 2A28      OR	R2,R24
    00D4 BA2B      OUT	0x1B,R2
(0089)   LCD_en_write();
    00D5 DFBD      RCALL	_LCD_en_write
    00D6 940E01EA  CALL	pop_gset1
    00D8 9508      RET
_LCD_set_xy:
  address              --> R20
  y                    --> R20
  x                    --> R22
    00D9 940E01E5  CALL	push_gset2
    00DB 2F42      MOV	R20,R18
    00DC 2F60      MOV	R22,R16
(0090) }
(0091) 
(0092) 
(0093) void LCD_set_xy( unsigned char x, unsigned char y )  //写地址函数
(0094) {
(0095)     unsigned char address;
(0096)     if (y == 0) address = 0x80 + x;
    00DD 2344      TST	R20
    00DE F419      BNE	0x00E2
    00DF 2F46      MOV	R20,R22
    00E0 5840      SUBI	R20,0x80
    00E1 C002      RJMP	0x00E4
(0097)     else   address = 0xc0 + x;
    00E2 2F46      MOV	R20,R22
    00E3 5440      SUBI	R20,0x40
(0098)     LCD_write_command( address);
    00E4 2F04      MOV	R16,R20
    00E5 DFB3      RCALL	_LCD_write_command
    00E6 940E01D9  CALL	pop_gset2
    00E8 9508      RET
_LCD_write_string:
  s                    --> R20
  Y                    --> R10
  X                    --> R22
    00E9 940E01E3  CALL	push_gset3
    00EB 2EA2      MOV	R10,R18
    00EC 2F60      MOV	R22,R16
    00ED 814E      LDD	R20,Y+6
    00EE 815F      LDD	R21,Y+7
(0099) }
(0100)   

⌨️ 快捷键说明

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