📄 main.lst
字号:
__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 E6E0 LDI R30,0x60
003D E0F0 LDI R31,0
003E E010 LDI R17,0
003F 36E0 CPI R30,0x60
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 E6E5 LDI R30,0x65
0046 E0F0 LDI R31,0
0047 E6A0 LDI R26,0x60
0048 E0B0 LDI R27,0
0049 E010 LDI R17,0
004A 36E5 CPI R30,0x65
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 940E007B CALL _main
_exit:
0053 CFFF RJMP _exit
FILE: E:\avr\2.1.6\main.c
(0001) //ICC-AVR application builder : 2007-5-29 15:21:23
(0002) // Target : M16
(0003) // Crystal: 7.3728Mhz
(0004)
(0005) #include <iom16v.h>
(0006) #include <macros.h>
(0007)
(0008) const unsigned char seg7_data[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};//0~F and "shut"
(0009)
(0010)
(0011) void port_init(void)
(0012) {
(0013) PORTA = 0xFF;
_port_init:
0054 EF8F LDI R24,0xFF
0055 BB8B OUT 0x1B,R24
(0014) DDRA = 0xFF;
0056 BB8A OUT 0x1A,R24
(0015) PORTB = 0x01; //PB0,是TIMER0的外部时钟输入脚(T0),需要设为输入,并且使能内部上拉
0057 E081 LDI R24,1
0058 BB88 OUT 0x18,R24
(0016) DDRB = 0x00;
0059 2422 CLR R2
005A BA27 OUT 0x17,R2
(0017) PORTC = 0x00; //m103 output only
005B BA25 OUT 0x15,R2
(0018) DDRC = 0x00;
005C BA24 OUT 0x14,R2
(0019) PORTD = 0x00;
005D BA22 OUT 0x12,R2
(0020) DDRD = 0x00;
005E BA21 OUT 0x11,R2
005F 9508 RET
(0021) }
(0022)
(0023) //TIMER0 initialize - prescale:Falling edge
(0024) // WGM: Normal
(0025) // desired value: 1KHz
(0026) // actual value: Out of range
(0027) void timer0_init(void)
(0028) {
(0029) TCCR0 = 0x00; //stop
_timer0_init:
0060 2422 CLR R2
0061 BE23 OUT 0x33,R2
(0030) TCNT0 = 0x00; //set count
0062 BE22 OUT 0x32,R2
(0031) OCR0 = 0x0A; //set compare十进制的十,十次按键后匹配,进入这里
0063 E08A LDI R24,0xA
0064 BF8C OUT 0x3C,R24
(0032) TCCR0 = 0x06; //start timer
0065 E086 LDI R24,6
0066 BF83 OUT 0x33,R24
0067 9508 RET
_timer0_comp_isr:
0068 922A ST R2,-Y
0069 B62F IN R2,0x3F
006A 922A ST R2,-Y
(0033) }
(0034)
(0035) #pragma interrupt_handler timer0_comp_isr:20
(0036) void timer0_comp_isr(void)
(0037) {
(0038) //compare occured TCNT0=OCR0
(0039) //按下键OCR0次后,会进入本中断
(0040) TCNT0 = 0x00;
006B 2422 CLR R2
006C BE22 OUT 0x32,R2
006D 9029 LD R2,Y+
006E BE2F OUT 0x3F,R2
006F 9029 LD R2,Y+
0070 9518 RETI
(0041) }
(0042)
(0043) //call this routine to initialize all peripherals
(0044) void init_devices(void)
(0045) {
(0046) //stop errant interrupts until set up
(0047) CLI(); //disable all interrupts
_init_devices:
0071 94F8 BCLR 7
(0048) port_init();
0072 DFE1 RCALL _port_init
(0049) timer0_init();
0073 DFEC RCALL _timer0_init
(0050)
(0051) MCUCR = 0x00;
0074 2422 CLR R2
0075 BE25 OUT 0x35,R2
(0052) GICR = 0x00;
0076 BE2B OUT 0x3B,R2
(0053) TIMSK = 0x02; //timer interrupt sources
0077 E082 LDI R24,2
0078 BF89 OUT 0x39,R24
(0054) SEI(); //re-enable interrupts
0079 9478 BSET 7
007A 9508 RET
(0055) //all peripherals are now initialized
(0056) }
(0057)
(0058) void main(void)
(0059) {
(0060) init_devices();
_main:
007B DFF5 RCALL _init_devices
007C C008 RJMP 0x0085
(0061) while(1)
(0062) {
(0063) PORTA = seg7_data[TCNT0];
FILE: <library>
007D E584 LDI R24,0x54
007E E090 LDI R25,0
007F B7E2 IN R30,0x32
0080 27FF CLR R31
0081 0FE8 ADD R30,R24
0082 1FF9 ADC R31,R25
0083 91E4 LPM R30,0(Z)
0084 BBEB OUT 0x1B,R30
0085 CFF7 RJMP 0x007D
0086 9508 RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -