📄 main.asm
字号:
;==================================================================================
; The information contained herein is the exclusive property of
; Sunplus Technology Co. And shall not be distributed, reproduced,
; or disclosed in whole in part without prior written permission.
; (C) COPYRIGHT 2004 SUNPLUS TECHNOLOGY CO.
; ALL RIGHTS RESERVED
; The entire notice above must be reproduced on all authorized copies.
;==================================================================================
;==================================================================================
; Project Name :
; Applied Body : SPMC65P2404A
; Firmware version:
; Programer :
; Date : 2004-8-24
; Description : he program presents an example that cope two level interrupt.
;
; Hardware Connect:
; Link File :
; IDE Version : V1.6.5
; BODY Version : V1.0.0A
;==================================================================================
.SYNTAX 6502 ;process standard 6502 addressing syntax
.LINKLIST ;generate linklist information
.SYMBOLS ;generate symbolic debug information
;************************************************************************************
;* *
;* System Register Define *
;* *
;************************************************************************************
.INCLUDE SPMC65P2404A.inc ;Define all hardware,Registers and ports.
;************************************************************************************
;************************************************************************************
;* *
;* Data memory Define *
;* *
;************************************************************************************
.PAGE0 ;define values in the range from 00h to FFh
;************************************************************************************
.DATA ;define data storage section
;************************************************************************************
;* *
;* Program Area *
;* *
;************************************************************************************
.CODE
;**********************************************************************************
;* *
;* Power on Reset Process *
;* *
;**********************************************************************************
V_Reset:
sei ;Disable interrupt
ldx #C_STACK_BOTTOM ;Initial stack pointer at $00ff
txs ;Transfer to stack point
jsr F_Tim0_Init ;init 4ms interrupt and IRQ0 interrupt
jsr F_IO_Init ;init PA as output,PB as input
cli
?L_Main_Loop: ;the example for test
nop
jmp ?L_Main_Loop
;====================================================================
; Function: F_Tim0_Init
; Description: Set 4ms interrupt in timer0 and IRQ0 in PB4
; Input: none
; Output: none
; Destroy: A
; Stacks: 1
;====================================================================
F_Tim0_Init:
lda #C_T08B_Timer ;Timer0 Function as 8 Bit Timer
sta P_TMR0_1_Ctrl0
lda #C_T0FCS_Div_128 ;DIV=1/128
sta P_TMR0_1_Ctrl1
lda #6 ;Preload counter= 166
sta P_TMR0_Preload ;8000000/128/250=250Hz=4ms
lda #C_INT_T0OIE
sta P_INT_Ctrl1 ;Timer0 overflow INT enable
lda #0
sta P_IRQ_Opt1
sta P_IRQ_Opt1 ;IRQ0(PB4)faling edge
lda #C_INT_IRQ0IE
sta P_INT_Ctrl0 ;interrupt enable
lda #$FF
sta P_INT_Flag0
sta P_INT_Flag1
rts
;====================================================================
; Function: F_IO_Init
; Description: init PA as output,PB as input
; Input: none
; Output: none
; Destroy: A
; Stacks: 1
;====================================================================
F_IO_Init:
lda #0
sta P_IOA_Attrib
lda #$FF
sta P_IOA_Dir
sta P_IOA_Data ;PA output high
sta P_IOA_Buf
lda #0
sta P_IOB_Attrib
lda #$00
sta P_IOB_Dir
sta P_IOB_Data ;PB input with pull low
sta P_IOB_Buf
rts
;**********************************************************************************
;* *
;* Interrupt Vector Table *
;* *
;**********************************************************************************
V_IRQ:
pha
lda P_INT_Flag0
and #C_INT_IRQ0IF ;IRQ0 INT comming?
bne ?L_IRQ0 ;yes
lda P_INT_Flag1
and #C_INT_T0OIF ;4ms INT comming?
bne ?L_Timer0 ;yes
jmp L_IntExit
;--------------------------------------------
;first level interrupt: 4ms INT
;--------------------------------------------
?L_Timer0:
lda #$FF
sta P_INT_Flag0 ;clear INT request flag
sta P_INT_Flag1
cli
lda #$FF
sta P_IOA_Data
nop
nop
nop
lda #$00
sta P_IOA_Data ;PA output falling edge to PB4,
;the falling edge creat second
;level interrupt(IRQ0 INT)
nop
nop
nop
nop
jmp L_IntExit
;--------------------------------------------
;second level interrupt: IRQ0 INT
;--------------------------------------------
?L_IRQ0:
nop
L_IntExit:
lda #$FF
sta P_INT_Flag0 ;clear INT request flag
sta P_INT_Flag1
pla
rti
V_NMI:
rti
VECTOR .SECTION
;*********************************************************************************
DW V_NMI ; may download program emulated either
DW V_Reset ; in internal memory or external memory
DW V_IRQ ; dw define two bytes interrupt vector
;**********************************************************************************
;* *
;* End of Interrupt Vector Table *
;* *
;**********************************************************************************
.END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -