Hardware Reference
In-Depth Information
hit1
ldab
CAN1RDLR
; get the byte count of incoming data
beq
rxfDone
; byte count 0, return
ldx
#v1_line1
; output “Voltage is”
jsr
puts2lcd
;
ldaa
#$C4
; set cursor to row 2 column 4
jsr
cmd2LCD
;
ldx
#CAN1RDSR0
; x points to data segment register 0
outLoop2
ldaa
1,x 1
jsr
putc2lcd
dbne
b,outLoop2
rxfDone
rti
t1_line1
fcc
“Temperature is”
dc.b
0
v1_line1
fcc
“Voltage is”
dc.b
0
The C language version (compiled by ICC12 compiler) of the service routine is as follows:
#include
“c:\iccv712\include\hcs12.h”
#include
“c:\iccv712\include\delay.h”
#include
“c:\iccv712\include\lcd_util.h”
void
RxISR(void);
void
open_can1(void);
char
*t1Msg 5 “Temperature is”;
char
*v1Msg 5 “Voltage is”;
int main (void)
{
asm( “ldd #_RxISR” );
//pass the interrupt vector of CAN1Rx interrupt
asm( “pshd” );
//
asm( “ldd #21” );
//place the vector number of CAN1Rx in D
asm( “ldx $EEA4” );
asm( “jsr 0,X” );
open_can1();
openLCD();
CAN1RIER 5 0x01;
/* enable CAN1 RXF interrupt only */
asm(“cli”);
while(1);
/* wait for RXF interrupt */
return 0;
}
; *********************************************************************
// The following function handles the RXF interrupt. It checks if the RXF flag
// is set. If not, return. It also ignores the RTR request.
; *********************************************************************
#pragma interrupt_handler RxISR
void RxISR (void)
{
char tmp,i,*ptr;
if (!(CAN1RFLG & RXF))
/* interrupt not caused by RXF, return */
return;
CAN1RFLG 5 RXF;
/* clear RXF flag */
tmp 5 CAN1IDAC & 0x07;
/* extract filter hit info */
if (tmp 55 0) {
/* filter 0 hit */
Search WWH ::




Custom Search