#include "c:\miniide\hcs12.inc" org $1000 org $2000 tbuf equ 0 ; tbuf offset from top of stack snd2can1 pshy pshb leas -1,sp ; allocate one byte for local variable sloop1 brset CAN1TFLG,$01,tb0 ; is transmit buffer 0 empty? brset CAN1TFLG,$02,tb1 ; is transmit buffer 1 empty? brset CAN1TFLG,$04,tb2 ; is transmit buffer 2 empty? bra sloop1 ; if necessary wait until one buffer is empty 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 accesible to user ldy #CAN1TIDR0 ; set y to point to the start of the transmit buffer ldab #7 ; always copy 7 words (place word count in B) cploop movw 2,x+,2,y+ 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 end