Hardware Reference
In-Depth Information
if (tb
55
0)
CAN1TFLG
5
0x01;
/* mark buffer 0 ready for transmission */
else if (tb
55
1)
CAN1TFLG
5
0x02;
/* mark buffer 1 ready for transmission */
else
CAN1TFLG
5
0x04;
/* mark buffer 2 ready for transmission */
}
▲
Example 13.6
▼
Write a program to send out the string “3.5 V” from CAN1 and use V1 as its identifier. Set
transmit buffer priority to the highest.
Solution:
The assembly program that performs the desired function is as follows:
org
$1000
tbuf0
ds
16
org
$2000
movb
#$56,tbuf0
; identifier V1
movb
#$3C,tbuf0
1
1
;
“
movb
#$40,tbuf0
1
2
;
“
movb
#0,tbuf0
1
3
;
“
movb
#$33,tbuf0
1
4
; data “3”
movb
#$2E,tbuf0
1
5
; data “.”
movb
#$35,tbuf0
1
6
; data “5”
movb
#$20,tbuf0
1
7
; data “ ”
movb
#$56,tbuf0
1
8
; data “V”
movb
#5,tbuf0
1
12
; data length (
5
5)
movb
#0,tbuf0
1
13
; set transmit buffer priority to highest
ldx
#tbuf0
jsr
snd2can1
; call subroutine to perform the actual transmission
swi
The sequence of C statements that performs the same function is as follows:
void snd2can1(char *ptr);
char tbuf0[16];
tbuf0[0]
5
'V';
/* identifier V1 */
tbuf0[1]
5
0x3C;
/* “ */
tbuf0[2]
5
0x40;
/* “ */
tbuf0[3]
5
0;
/* “ */
tbuf0[4]
5
'3';
/* letter 3 */
tbuf0[5]
5
'.';
/* character.*/
tbuf0[6]
5
'5';
/* letter 5 */
tbuf0[7]
5
0x20;
/* space */
tbuf0[8]
5
'V';
/* letter V */
tbuf0[12]
5
5;
/* data length */
tbuf0[13]
5
0;
/* tbuf0 priority */
snd2can1(tbuf0);
▲
Search WWH ::
Custom Search