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

📄 main.lst

📁 一个关于AVR单片机的例程
💻 LST
字号:
__start:
__text_start:
    002A E5CF      LDI	R28,0x5F
    002B E0D4      LDI	R29,4
    002C BFCD      OUT	0x3D,R28
    002D BFDE      OUT	0x3E,R29
    002E 51C0      SUBI	R28,0x10
    002F 40D0      SBCI	R29,0
    0030 EA0A      LDI	R16,0xAA
    0031 8308      STD	Y+0,R16
    0032 2400      CLR	R0
    0033 E6E0      LDI	R30,0x60
    0034 E0F0      LDI	R31,0
    0035 E010      LDI	R17,0
    0036 36E0      CPI	R30,0x60
    0037 07F1      CPC	R31,R17
    0038 F011      BEQ	0x003B
    0039 9201      ST	R0,Z+
    003A CFFB      RJMP	0x0036
    003B 8300      STD	Z+0,R16
    003C E5E4      LDI	R30,0x54
    003D E0F0      LDI	R31,0
    003E E6A0      LDI	R26,0x60
    003F E0B0      LDI	R27,0
    0040 E010      LDI	R17,0
    0041 35E4      CPI	R30,0x54
    0042 07F1      CPC	R31,R17
    0043 F021      BEQ	0x0048
    0044 95C8      LPM
    0045 9631      ADIW	R30,1
    0046 920D      ST	R0,X+
    0047 CFF9      RJMP	0x0041
    0048 940E0073  CALL	_main
_exit:
    004A CFFF      RJMP	_exit
FILE: D:\桌面\实验教程\LED应用\PWM控制LED亮度\main.c
(0001) //ICC-AVR application builder : 2007-1-31 21:10:52
(0002) // Target : M16
(0003) // Crystal: 7.3728Mhz
(0004) 
(0005) #include <iom16v.h>
(0006) #include <macros.h>
(0007) 
(0008) void port_init(void)
(0009) {
(0010)  PORTA = 0x00;
_port_init:
    004B 2422      CLR	R2
    004C BA2B      OUT	0x1B,R2
(0011)  DDRA  = 0x00;
    004D BA2A      OUT	0x1A,R2
(0012)  PORTB = 0x00;
    004E BA28      OUT	0x18,R2
(0013)  DDRB  = 0x08;
    004F E088      LDI	R24,0x8
    0050 BB87      OUT	0x17,R24
(0014)  PORTC = 0x00; //m103 output only
    0051 BA25      OUT	0x15,R2
(0015)  DDRC  = 0x00;
    0052 BA24      OUT	0x14,R2
(0016)  PORTD = 0x00;
    0053 BA22      OUT	0x12,R2
(0017)  DDRD  = 0x00;
    0054 BA21      OUT	0x11,R2
    0055 9508      RET
(0018) }
(0019) 
(0020) #pragma interrupt_handler timer0_comp_isr:20
(0021) void timer0_comp_isr(void)
(0022) {
_timer0_comp_isr:
    0056 9518      RETI
(0023)  //compare occured TCNT0=OCR0
(0024) }
(0025) 
(0026) //TIMER0 initialize - prescale:64
(0027) // WGM: CTC
(0028) // desired value: 1KHz
(0029) // actual value:  0.993KHz (-0.7%)
(0030) void timer0_init(void)
(0031) {
(0032)  TCCR0 = 0x00; //stop
_timer0_init:
    0057 2422      CLR	R2
    0058 BE23      OUT	0x33,R2
(0033)  TCNT0 = 0x8D; //set count
    0059 E88D      LDI	R24,0x8D
    005A BF82      OUT	0x32,R24
(0034)  OCR0  = 0x73;  //set compare
    005B E783      LDI	R24,0x73
    005C BF8C      OUT	0x3C,R24
(0035)  TCCR0 = 0x0B; //start timer
    005D E08B      LDI	R24,0xB
    005E BF83      OUT	0x33,R24
    005F 9508      RET
_timer0_ovf_isr:
    0060 938A      ST	R24,-Y
    0061 B78F      IN	R24,0x3F
    0062 938A      ST	R24,-Y
(0036) }
(0037) 
(0038) #pragma interrupt_handler timer0_ovf_isr:10
(0039) void timer0_ovf_isr(void)
(0040) {
(0041)  TCNT0 = 0x8D; //reload counter value
    0063 E88D      LDI	R24,0x8D
    0064 BF82      OUT	0x32,R24
    0065 9189      LD	R24,Y+
    0066 BF8F      OUT	0x3F,R24
    0067 9189      LD	R24,Y+
    0068 9518      RETI
(0042) }
(0043) 
(0044) //call this routine to initialize all peripherals
(0045) void init_devices(void)
(0046) {
(0047)  //stop errant interrupts until set up
(0048)  CLI(); //disable all interrupts
_init_devices:
    0069 94F8      BCLR	7
(0049)  port_init();
    006A DFE0      RCALL	_port_init
(0050)  timer0_init();
    006B DFEB      RCALL	_timer0_init
(0051) 
(0052)  MCUCR = 0x00;
    006C 2422      CLR	R2
    006D BE25      OUT	0x35,R2
(0053)  GICR  = 0x00;
    006E BE2B      OUT	0x3B,R2
(0054)  TIMSK = 0x01; //timer interrupt sources
    006F E081      LDI	R24,1
    0070 BF89      OUT	0x39,R24
(0055)  SEI(); //re-enable interrupts
    0071 9478      BSET	7
    0072 9508      RET
(0056)  //all peripherals are now initialized
(0057) }
(0058) 
(0059) void main()
(0060) {
(0061)  init_devices();
FILE: <library>
_main:
    0073 DFF5      RCALL	_init_devices
    0074 9508      RET

⌨️ 快捷键说明

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