Hardware Reference
In-Depth Information
tb0
movb
#0,tbuf,sp
; mark transmit buffer 0 empty
bra
tcopy
tb1
movb
#1,tbuf,sp
; mark transmit buffer 1 empty
bra
tcopy
tb2
movb
#2,tbuf,sp
; mark transmit buffer 2 empty
tcopy
movb
CAN1TFLG,CAN1TBSEL
; make the empty transmit buffer accessible
ldy
#CAN1TIDR0
; set y to point to the start of the transmit buffer
ldab
#7
; always copy seven words (place word count in B)
cploop
movw
2,x 1 ,2,y 1
dbne
b,cploop
ldab
tbuf,sp
cmpb
#0
beq
istb0
cmpb
#1
beq
istb1
movb
#$04,CAN1TFLG
; mark buffer 2 ready for transmission
bra
dcopy
istb0
movb
#$01,CAN1TFLG
; mark buffer 0 ready for transmission
bra
dcopy
istb1
movb
#$02,CAN1TFLG
; mark buffer 1 ready for transmission
dcopy
leas
1,sp
; deallocate local variables
pulb
puly
rts
The C language version of the function is as follows:
void snd2can1(char *ptr)
{
int tb,i,*pt1,*pt2;
pt1 5 (int *)ptr;
/* convert to integer pointer */
while(1) {
/* find an empty transmit buffer */
if(CAN1TFLG & 0x01){
tb 5 0;
break;
}
if(CAN1TFLG & 0x02){
tb 5 1;
break;
}
if(CAN1TFLG & 0x04){
tb 5 2;
break;
}
}
CAN1TBSEL 5 CAN1TFLG;
/* make empty transmit buffer accessible */
pt2 5 (int *)&CAN1TIDR0;
/* pt2 points to the IDR0 of TXFG */
for (i 5 0; i < 7; i 11 )
/* copy the whole transmit buffer */
*pt2 11 5 *pt1 11 ;
Search WWH ::




Custom Search