?? dip20~1.lst
字號:
AVRASM ver. 1.30 DIP20~1.ASM Tue Jan 01 21:06:18 2002
;************* 應(yīng)用筆記 DIP20.asm ************************
;*
;* 標(biāo)題: 測試DIP20 AVR單片機(jī)B口、D口功能
;* 版本: 1.0
;*最后更新日期: 2000.08.08
;*
;* 支援 E-mail: gzsl@sl.com.cn
;*
;* 描述
;* 測試DIP20 AVR單片機(jī)B口、D口功能,LED逐位移位,移位速度會變化
;* 作者: SL.
;*程序適用于所有單片機(jī)
;***************************************************************************
; AT90S1200引腳圖 "*"表示引腳接LED發(fā)光二極管
; "↓"表示燈亮移位方向
; /RST 。1 20 。VCC
; PD0 ↑* 。 。* ↓ PB7
; PD1 ↑* 。 。* ↓ PB6
; XTAL2 。 。* ↓ PB5
; XTAL1 。 。* ↓ PB4
; PD2 ↑* 。 。* ↓ PB3
; PD3 ↑* 。 。* ↓ PB2
; PD4 ↑* 。 。* ↓ PB1
; PD5 ↑* 。 。* ↓ PB0
; GND 。10 11 。* ↓ PD6
;
.include "1200def.inc"
;***************************************************************************
;* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y
;*
;* Number :AVR000
;* File Name :"1200def.inc"
;* Title :Register/Bit Definitions for the AT90S1200
;* Date :99.01.28
;* Version :1.30
;* Support telephone :+47 72 88 43 88 (ATMEL Norway)
;* Support fax :+47 72 88 43 99 (ATMEL Norway)
;* Support E-Mail :avr@atmel.com
;* Target MCU :AT90S1200
;*
;* DESCRIPTION
;* When including this file in the assembly program file, all I/O register
;* names and I/O register bit names appearing in the data book can be used.
;*
;* The Register names are represented by their hexadecimal addresses.
;*
;* The Register Bit names are represented by their bit number (0-7).
;*
;* Please observe the difference in using the bit names with instructions
;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc"
;* (skip if bit in register set/cleared). The following example illustrates
;* this:
;*
;* in r16,PORTB ;read PORTB latch
;* sbr r16,(1<<PB6)+(1<<PB5) ;set PB6 and PB5 (use masks, not bit#)
;* out PORTB,r16 ;output to PORTB
;*
;* in r16,TIFR ;read the Timer Interrupt Flag Register
;* sbrc r16,TOV0 ;test the overflow flag (use bit#)
;* rjmp TOV0_is_set ;jump if set
;* ... ;otherwise do something else
;***************************************************************************
;***** Specify Device
.device AT90S1200
;***** I/O Register Definitions
.equ SREG =$3f
.equ GIMSK =$3b
.equ TIMSK =$39
.equ TIFR =$38
.equ MCUCR =$35
.equ TCCR0 =$33
.equ TCNT0 =$32
.equ WDTCR =$21
.equ EEAR =$1e
.equ EEDR =$1d
.equ EECR =$1c
.equ PORTB =$18
.equ DDRB =$17
.equ PINB =$16
.equ PORTD =$12
.equ DDRD =$11
.equ PIND =$10
.equ ACSR =$08
;***** Bit Definitions
.equ INT0 =6
.equ TOIE0 =1
.equ TOV0 =1
.equ SE =5
.equ SM =4
.equ ISC01 =1
.equ ISC00 =0
.equ CS02 =2
.equ CS01 =1
.equ CS00 =0
.equ WDE =3
.equ WDP2 =2
.equ WDP1 =1
.equ WDP0 =0
.equ EEWE =1
.equ EERE =0
.equ PB7 =7
.equ PB6 =6
.equ PB5 =5
.equ PB4 =4
.equ PB3 =3
.equ PB2 =2
.equ PB1 =1
.equ PB0 =0
.equ DDB7 =7
.equ DDB6 =6
.equ DDB5 =5
.equ DDB4 =4
.equ DDB3 =3
.equ DDB2 =2
.equ DDB1 =1
.equ DDB0 =0
.equ PINB7 =7
.equ PINB6 =6
.equ PINB5 =5
.equ PINB4 =4
.equ PINB3 =3
.equ PINB2 =2
.equ PINB1 =1
.equ PINB0 =0
.equ PD6 =6
.equ PD5 =5
.equ PD4 =4
.equ PD3 =3
.equ PD2 =2
.equ PD1 =1
.equ PD0 =0
.equ DDD6 =6
.equ DDD5 =5
.equ DDD4 =4
.equ DDD3 =3
.equ DDD2 =2
.equ DDD1 =1
.equ DDD0 =0
.equ PIND6 =6
.equ PIND5 =5
.equ PIND4 =4
.equ PIND3 =3
.equ PIND2 =2
.equ PIND1 =1
.equ PIND0 =0
.equ ACD =7
.equ ACO =5
.equ ACI =4
.equ ACIE =3
.equ ACIS1 =1
.equ ACIS0 =0
.equ XRAMEND =0
.equ E2END =3F
.equ FLASHEND=1FF
.equ INT0addr=$001 ;External Interrupt0 Vector Address
.equ OVF0addr=$002 ;Overflow0 Interrupt Vector Address
.equ ACIaddr =$003 ;Analog Comparator Interrupt Vector Address
.def ZL =r30
000000 c004 rjmp RESET ;Reset Handle
.org $005
RESET:
000005 ef0f LDI r16,0XFF ;設(shè)B口、D口為輸出
000006 bb07 OUT ddrb,R16 ;設(shè)b口方向寄存器為輸出
000007 bb01 OUT DDRD,R16 ;設(shè)D口方向寄存器為輸出
000008 bb02 out portd,r16 ;關(guān)D口LED,OK-AVR實驗器硬件設(shè)定高電平LED燈滅
000009 bb08 out portb,r16 ;關(guān)B口LED,OK-AVR實驗器硬件設(shè)定高電平LED燈滅
00000a e018 start: ldi R17,0x08 ;循環(huán)次數(shù)
00000b e72f ldi r18,0x7f ;0b0111 1111,OK-AVR實驗器硬件設(shè)定低電平LED燈亮
00000c bb28 loop: out portb,r18 ;B口.7位 LED燈亮
00000d 9408 sec ;c=1
00000e 9527 ror r18 ;通過進(jìn)位右循環(huán)
00000f d009 rcall delay ;調(diào)用延時子程序
000010 951a dec r17 ;-1
000011 f7d1 brne loop ;檢測R17循環(huán)不0為轉(zhuǎn)移,為0按順序執(zhí)行
000012 bb08 out portb,r16 ;關(guān)B口
000013 eb2f ldi r18,0xbf ; 0b1011 1111
000014 bb22 out portd,r18 ;D口.6位 LED燈亮
000015 d003 rcall delay ;延時
000016 ef2f ldi r18,0xff
000017 bb22 out portd,r18 ;關(guān)D口
000018 cff1 rjmp start ;循環(huán)
000019 e0da delay: ldi r29,0x0a ;延時子程序
00001a 95ea delay1: dec r30 ;復(fù)位后R30=0X00
00001b f7f1 brne delay1 ;R30不為0轉(zhuǎn),為0按順序執(zhí)行
00001c 95fa dec r31 ;復(fù)位后R31=0X00
00001d f7e1 brne delay1 ;R30不為0轉(zhuǎn),為0按順序執(zhí)行
00001e 95da dec r29 ;復(fù)位后R29=0X00
00001f f7d1 brne delay1 ;R29不為0轉(zhuǎn),為0按順序執(zhí)行
000020 9508 ret ;子程序返回
Assembly complete with no errors.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -