#include "c:\miniIDE\hcs12.inc" org $2000 lds #$2000 ; set up stack pointer jsr openlcd ; configure the LCD kit jsr OpenCan1 movw #can1Rx_ISR,UserMSCAN1Rx ; set up CAN1 receive interrupt vector movb #$01,CAN1RIER ; enable RXF interrupt only cli ; enable interrupt globally forever nop ; wait for CAN receive interrupt bra forever ; " ; ********************************************************************************* ; The following is the service routine for RXF interrupt. It only services hit 0 ; and hit 1. It ignores the RTR. ; ********************************************************************************* can1Rx_ISR brset CAN1RFLG,RXF,RxfSet ; is the RXF flag set to 1? rti ; if not, do nothing RxfSet ldab CAN1IDAC ; check into IDHIT bits andb #$07 ; mask out higher 5 bits beq hit0 ; filter 0 hit? cmpb #1 ; filter 1 hit? beq hit1 rti ; not hit 0 nor hit 1, do thing hit0 ldab CAN1RDLR ; get the byte count of incoming data beq rxfDone ; byte count 0, return ldx #t1_line1 ; output "Temperature is" jsr puts2lcd ; " ldx #CAN1RDSR0 outLoop1 ldaa 1,x+ ; outputone byte at a time jsr putc2lcd ; " dbne b,outLoop1 ; " rti hit1 ldab CAN1RDLR ; get the byte count of incoming data beq rxfDone ; byte count 0, return ldx #v1_line1 ; output "Voltage is" jsr puts2lcd ; " ldx #CAN1RDSR0 ; x points to data segment register 0 outLoop2 ldaa 1,x+ jsr putc2lcd dbne b,outLoop2 rxfDone rti t1_line1 fcc "Temperature is" dc.b 0 v1_line1 fcc "Voltage is" dc.b 0 ; ************************************************************************************** ; The following function configures CAN1 to accept messages having extended identifiers ; "T1" and "V1" and use the timing parameters computed in Example 13.3 to operate. ; ************************************************************************************** OpenCan1 bset CAN1CTL0,INITRQ ; request to enter initialization mode w1 brclr CAN1CTL1,INITAK,w1 ; make sure initialization mode is entered movb #$84,CAN1CTL1 ; enable CAN1,select oscillator as clock source ; enable wake up filter movb #$41,CAN1BTR0 ; set jump width to 2 Tq, prescaler set to 2 movb #$18,CAN1BTR1 ; set phase_seg2 to 2 Tq, phase_seg1 to 2 Tq, set ; prop_seg to 7 Tq movb #$54,CAN1IDAR0 ; acceptance identifier 'T' movb #$3C,CAN1IDAR1 ; acceptance identifier '1' movb #$40,CAN1IDAR2 ; " movb #$00,CAN1IDAR3 ; " movb #$00,CAN1IDMR0 ; acceptance filer for extended identifier "T1" movb #$00,CAN1IDMR1 ; " movb #$3F,CAN1IDMR2 ; " movb #$FF,CAN1IDMR3 ; " movb #$56,CAN1IDAR4 ; acceptance identifier 'V' movb #$3C,CAN1IDAR5 ; acceptance identifier '1' movb #$40,CAN1IDAR6 ; " movb #$00,CAN1IDAR7 ; " movb #$00,CAN1IDMR4 ; acceptance filer for extended identifier "P1" movb #$00,CAN1IDMR5 ; " movb #$3F,CAN1IDMR6 ; " movb #$FF,CAN1IDMR7 ; " clr CAN1IDAC ; set two 32-bit filter mode bclr CAN1CTL0,INITRQ ; leave initialization mode movb #$24,CAN1CTL0 ; stop MSCAN clock on wait mode, enable wakeup rts #include "c:\miniIDE\lcd_util_dragon12.asm" #include "c:\miniIDE\delay.asm" end