buttonint.asm
来自「This program is distributed in the hope 」· 汇编 代码 · 共 115 行
ASM
115 行
;+---------------------------------------------------------------------------+;| |;| 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. |;| |;| |;+---------------------------------------------------------------------------+; Interrupt test of the Cypress EZ-USB; Makes a LED connected to PB4 toggle on each interrupt recieved on #INT5;;+-------------------------------------+;| 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 0x00ljmp init;#INT5 Vector.org 0x5Bljmp int5 .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, #00100000b ; Besides PB5 -> #int5 movx @dptr, a mov dptr, #OEB ; Pin PB4 is an output pin mov a, #00010000b movx @dptr, a mov IE, #10000000b ; Enable interrupts mov EIE, #00001000b ; Enable #INT5 ;+--------------+;| Main program |;+--------------+ ;begin: nop ljmp begin ;+-----------------------------+;| Interrupt 5 service routine |;+-----------------------------+;int5: mov dptr, #PINSB ; Read the status on PB movx a, @DPTR cpl acc.4 ; Invert the PB4 bit mov dptr, #OUTB ; Write the result into the PB register movx @dptr, a mov a, EXIF ; Clear the #int5 interrupt flag clr acc.7 mov EXIF, a reti
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?