Specifications
Program Examples
B-21
Program Examples
;===============================================================================
* File name : REM_ANS.asm *
* Description : PROGRAM TO INITIATE AUTO–ANSWER TO A REMOTE FRAME *
* REQUEST IN CAN *
* The two CAN modules must be connected to each other with appropriate *
* termination resistors. Reception and transmission by MBX2. Low priority *
* interrupt used. Transmit acknowledge for MBX2 is set after running this *
* program and the message is transmitted.To be used along with REM_REQ.asm *
* PERIPHERAL CODE : A, TEST CODE : 0 After successful completion of *
* this program, the value A000 must be present in 3A0h (DM) *
* Error code:A001 –– Remote request not received from the remote node *
;===============================================================================
.title ”REM_ANS” ; Title
.include 240x.h ; Variable and register declaration
.include vector.h ; Vector label declaration
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; Constant definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
DP_PF1 .set 0E0h ; Page 1 of peripheral file (7000h/80h
DP_CAN .set 0E2h ; CAN Register (7100h)
DP_CAN2 .set 0E4h ; CAN RAM (7200h)
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; M A C R O – Definitions
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
KICK_DOG .macro ; Watchdog reset macro
LDP #00E0h
SPLK #05555h, WDKEY
SPLK #0AAAAh, WDKEY
LDP #0h
.endm
;===============================================================================
; M A I N C O D E – starts here
;===============================================================================
.text
START: SETC INTM ; Disable interrupts
LDP #DP_PF1
SPLK #0010h,SCSR1 ; Enable clock to CAN module
SPLK 06Fh,WDCR ; Disable Watchdog
KICK_DOG
LDP #7h ; Write error code to start with
SPLK #0A001h,020h ; at 3A0h in B1 memory
LDP #225
SPLK #00C0H,MCRB ; Configure CAN pins
LAR AR0,#300h ; AR0 => Copy CAN RAM (B0)
LAR AR1,#3h ; AR1 => counter
LAR AR2,#7214h ; AR2 => MBX2










