📄 isr_spi2.s
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: isr_spi2.s,v $
; Revision 1.3 2005/04/04 23:43:55 VasukiH
; Updates to comments in file header
;
; Revision 1.2 2005/04/04 23:15:25 VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.1.1.1 2003/08/23 00:38:32 VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool Version
; --------------------------------------------------------------------------
; MPLAB IDE 7.0
; MPLAB C30 Toolsuite 1.30
; dsPICDEM(TM) Processor Board 1.10
; --------------------------------------------------------------------------
;
; File Notes:
; 1. SPI2 ISR routine has three modes of operation:
; a. In the normal mode, it transmits one control byte 0xA8 and one
; data (ASCII) byte alternately until the char count has reached zero.
; 0xA8 increments ChrPos to the next location.
; b. In some cases, ChrPos increments are not required. based on the value
; of a flag variable, the control byte transmission may be skipped.
; c. When Screen 4 (DTMF) screen chars are transmitted, the cursor is
; initialized and the ScreenSelection variable is incremented to 5.
; This ensures that INT2 pin inputs are treated only as cursor position
; changes.
;
;END_HEADER
.include "p30fxxxx.inc"
.global __SPI2Interrupt
.global LCDDataPtr
.global CtrlOrData
.global LcdCharCnt
.section .nbss, bss, near
LcdCharCnt: .space 2
bufcnt: .space 2
.section .ndata, data, near
CtrlOrData: .hword 0xFFFF
LCDDataPtr: .hword POR_disp
.section .text
__SPI2Interrupt:
push.d w0 ;Context save
bset LATG, #LATG9 ;Deselect Slave LCD controller
bclr IFS1, #SPI2IF ;clear interrupt flag
bclr SPI2STAT, #SPIROV ;Clear overflow flag
mov.b SPI2BUF, WREG ;Perform read of received byte buffer count
cp0 LcdCharCnt ;Check if the character count has reached 0
bra z, exit_SPI2_isr2 ;If so, then exit ISR
cp0 BypassCtrl ;Check if "A8" Ctrl chars need to be bypassed
bra nz, bypassCtrlChars ;If so, don't check whether next byte is control
;or data byte
cp0 CtrlOrData ;Else, check if byte to be transmitted is
;control or data byte
bra nz, FetchCtrlByte ;If it is, then fetch control byte 0xA8
setm CtrlOrData ;Else, set flag to control byte for next trx
bypassCtrlChars:
mov LCDDataPtr, w1 ;Move data byte address to w1
mov.b [w1++], w0 ;Read the data byte
dec LcdCharCnt ;Decrement count
mov w1, LCDDataPtr ;Update tx byte address for next transmission
bclr LATG, #LATG9 ;Enable SPI reception by LCD controller (SS pin low)
mov.b WREG, SPI2BUF ;Send byte to LCD controller
exit_SPI2_isr1:
pop.d w0 ;Restore context
retfie ;Return from interrupt
FetchCtrlByte:
clr CtrlOrData ;Clear flag for data trx
mov.b #0xA8, w0 ;Move control byte to w0
bclr LATG, #LATG9 ;Enable SPI reception by LCD controller (SS pin low)
mov.b WREG, SPI2BUF ;Send byte to LCD controller
pop.d w0 ;Restore context
retfie ;Return from interrupt
exit_SPI2_isr2:
mov #4, w0
cp ScreenSelection ;If current ScreenSelection is 4
bra nz, exit ;and character count has reached zero
btsc BypassCtrl, #0 ;then transmit initial cursor settings
bra exit_SPI_isr3
mov #5, w0
mov WREG, LcdCharCnt
mov #Cursor_disp1, w0
mov w0, LCDDataPtr
setm BypassCtrl ;bypass 0xA8 control byte check for next
;5 chars
mov.b SPI2BUF, WREG
mov.b #0x8C, w0 ;Send Cursor On command
bclr LATG, #LATG9 ;Select Slave LCD controller
mov.b WREG, SPI2BUF
exit:
pop.d w0
retfie
exit_SPI_isr3:
inc ScreenSelection ;If screen4 and subsequent 5 special chars
;were transmitted, increment screen to screen5
;Screen5 will retain the DTMF screen and manage
;movement of the blinking cursor
pop.d w0
bclr PORTD, #RD11
retfie
.end ;EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -