led2.asm

来自「This program is distributed in the hope 」· 汇编 代码 · 共 122 行

ASM
122
字号
;+---------------------------------------------------------------------------+;|                                                                           |;| Copyright (C) 2002,  Tom De Rybel                                         |;|                      on1dcd@hotmail.com                                   |;|                                                                           |;| This program is free software; you can redistribute it and/or             |;| modify it under the terms of the GNU General Public License               |;| as published by the Free Software Foundation; either version 2            |;| of the License, or any later version.                                     |;|                                                                           |;| This program is distributed in the hope that it will be useful,           |;| but WITHOUT ANY WARRANTY; without even the implied warranty of            |;| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |;| GNU General Public License for more details.                              |;|                                                                           |;| You should have received a copy of the GNU General Public License         |;| along with this program; if not, write to the Free Software               |;| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 |;|                                                                           |;|                                                                           |;+---------------------------------------------------------------------------+; First test of the Cypress EZ-USB; Makes a LED connected to PB4 blink;; Many thanks to Mr. Tony Cureington for helping me out with this one.;;+-------------------------------------+;| Declaration of the EZ-USB registers |;+-------------------------------------+.equ DPL1,	0x84.equ DPH1,	0x85.equ DPS,	0x86.equ CKCON,	0x8E.equ SPC_FNC,	0x8F.equ EXIF,	0x91.equ MPAGE,	0x92.equ SCON1,	0xC0.equ SBUF1,	0xC1.equ EICON,	0xD8.equ EIE,	0xE8.equ EIP,	0xF8		.equ CPUCS,     0x7F92	.equ PORTACFG, 	0x7F93.equ PORTBCFG, 	0x7F94.equ PORTCCFG, 	0x7F95.equ OUTA,     	0x7F96	.equ OUTB,     	0x7F97.equ OUTC,     	0x7F98.equ PINSA,    	0x7F99.equ PINSB,    	0x7F9A.equ PINSC,    	0x7F9B.equ OEA,      	0x7F9C.equ OEB,      	0x7F9D.equ OEC,      	0x7F9E;+-------------------+;| Interrupt vectors |;+-------------------+;;Reset Vector.org 0x0000ljmp init.org 0x0100;+-------------------------+;| Initialisation sequence |;+-------------------------+    init:	;;mov	0x92, #0x7F	; tc, allows movx Ri to access ez-usb memory	mov dptr, #PORTBCFG	; All pins are standard PB pins	mov a, #00000000b	movx @dptr, a		mov dptr, #OEB		; Pin PB4 is an output pin	mov a, #00010000b	movx @dptr, a;+--------------+;| Main program |;+--------------+		begin:			mov dptr, #OUTB	mov a, #00010000b	movx @dptr, a	lcall  Wait100msec	lcall  Wait100msec	lcall  Wait100msec		mov dptr, #OUTB	mov a, #00000000b	movx @dptr, a	lcall  Wait100msec	lcall  Wait100msec	lcall  Wait100msec	ljmp begin;+---------------------------------------------------------------------+;| Timing loop taken from the buttons and lights example in USB Design |;| by Example.                                                         |;+---------------------------------------------------------------------+Wait100msec:        mov     r0, #100Wait1msec:                      ; A delay loop        mov     dptr,#-1200More:   inc     dptr            ; 3 cycles        mov     a,dpl           ; + 2        orl     a,dph           ; + 2        jnz     More            ; + 3 = 10 cycles x 1200 = 1msec        djnz    r0, Wait1msec   ;         ret

⌨️ 快捷键说明

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