-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathDLOG4CHC.asm
executable file
·160 lines (126 loc) · 5.87 KB
/
DLOG4CHC.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
;==============================================================================
; File name : DLOG4CHC.ASM
;
; Originator : Advanced Embeeded Control (AEC)
; Texas Instruments Inc.
;
; Description : 4-Channel Data logging module
;
; Date : 02/01/2002 (DD/MM/YYYY)
;==============================================================================
; Routine Name: data_log_update
;
; C prototype : void DLOG_4CH_update(DLOG_4CH_handle);
; void DLOG_4CH_init(DLOG_4CH_handle);
;
; The struct object is defined in the header file "dlog_4ch.h" as follows:
;
; typedef struct {
; long task; /* Variable: Task address pointer */
; int *iptr1; /* Input: First input pointer (Q15) */
; int *iptr2; /* Input: Second input pointer (Q15) */
; int *iptr3; /* Input: Third input pointer (Q15) */
; int *iptr4; /* Input: Fourth input pointer (Q15) */
; int trig_value; /* Input: Trigger point (Q15) */
; int prescalar; /* Parameter: Data log prescale */
; int skip_cntr; /* Variable: Data log skip counter */
; int cntr; /* Variable: Data log counter */
; long write_ptr; /* Variable: Graph address pointer */
; int size; /* Parameter: Maximum data DLOG_4CH_buffer */
; int (*init)(); /* Pointer to init function */
; int (*update)(); /* Pointer to update function */
; } DLOG_4CH;
;==============================================================================
; External Reference
.def _DLOG_4CH_update
.def _DLOG_4CH_init
; Data log buffer definition
BUFF_SIZE .set 0C8h
DLOG_4CH_buff1 .usect "DLOG", BUFF_SIZE
DLOG_4CH_buff2 .usect "DLOG", BUFF_SIZE
DLOG_4CH_buff3 .usect "DLOG", BUFF_SIZE
DLOG_4CH_buff4 .usect "DLOG", BUFF_SIZE
;==============================================================================
; Initialization Function
;==============================================================================
_DLOG_4CH_init:
MOVL XAR5,#POS_TRIG_S1
MOVL *XAR4,XAR5 ; task=#POS_TRIG_S1
ADDB XAR4,#10 ; XAR4->trig_value
MOV *+XAR4[2],#0
MOVL XAR5,#DLOG_4CH_buff1
MOVL *+XAR4[4],XAR5 ; write_ptr=DLOG_4CH_buff1
MOV AL,*+XAR4[6] ; ACC=size
MOV *+XAR4[3],AL ; cntr=size
LRETR
;==============================================================================
; Datalog Update Function
;==============================================================================
_DLOG_4CH_update:
SETC SXM
MOVL XAR5,XAR4 ; XAR4->task
MOVL XAR7,*XAR4++ ; XAR4->iptr1, XAR7=task
ADDB XAR5,#10 ; XAR5->trig_value
LB *XAR7 ; Branch to TASK
POS_TRIG_S1:
MOV ACC,*XAR5 ; ACC=trig_value
MOVL XAR6,*XAR4 ; XAR6=iptr1
SUB ACC,*XAR6 ; ACC=(trig_value - *iptr1)
BF DL_EXIT,LEQ ; Exit if ACC <= 0
MOVL XAR6,#POS_TRIG_S2
MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
LRETR
POS_TRIG_S2:
MOV ACC,*XAR5 ; ACC=trig_value
MOVL XAR6,*XAR4 ; XAR6=iptr1
SUB ACC,*XAR6 ; ACC=(trig_value - *iptr1)
BF DL_EXIT,GEQ ; Exit if ACC >= 0
MOVL XAR6,#DL_TRIGGERED
MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
LRETR
DL_TRIGGERED:
INC *+XAR5[2] ; skip_cntr=skip_cntr+1
MOV ACC,*+XAR5[2] ; ACC=skip_cntr
SUB ACC,*+XAR5[1] ; ACC=skip_cntr-prescalar
SBF DL_EXIT,NEQ ; if (skip_cntr+1) < prescalar, then exit
MOV *+XAR5[2],#0 ; skip_cntr=0
MOV ACC,*+XAR5[3] ; ACC=cntr
SBF DLOG_END,EQ
DEC *+XAR5[3] ; cntr=cntr-1
ADDB XAR5,#4 ; XAR5->write_ptr
MOVL XAR6,*XAR5 ; XAR6=write_ptr
ADDB XAR6,#1 ; XAR6=write_ptr+1
MOVL *XAR5,XAR6 ; write_ptr=write_ptr + 1
SUBB XAR6,#1 ; XAR6=write_ptr
MOV AR0,#BUFF_SIZE ; AR0=BUFF_SIZE
; Log sample pointed by IPTR1
MOVL XAR7,*XAR4++ ; XAR7=iptr1
MOV AL,*XAR7 ; AL=*iptr1
NOP *,ARP6
MOV *0++,AL ; *write_ptr=*iptr1, XAR6=write_ptr+size
; Log sample pointed by IPTR2
MOVL XAR7,*XAR4++ ; XAR7=iptr2
MOV AL,*XAR7 ; AL=*iptr2
NOP *,ARP6
MOV *0++,AL ; *write_ptr=*iptr2, XAR6=write_ptr+size
; Log sample pointed by IPTR3
MOVL XAR7,*XAR4++ ; XAR7=iptr3
MOV AL,*XAR7 ; AL=*iptr3
NOP *,ARP6
MOV *0++,AL ; *write_ptr=*iptr3, XAR6=write_ptr+size
; Log sample pointed by IPTR4
MOVL XAR7,*XAR4++ ; XAR7=iptr4
MOV AL,*XAR7 ; AL=*iptr4
NOP *,ARP6
MOV *0++,AL ; *write_ptr=*iptr4, XAR6=write_ptr+size
LRETR
; Reinitialise the module to log the data when the logging is triggered next
DLOG_END:
MOVL XAR6,#DLOG_4CH_buff1
MOVL *+XAR5[4],XAR6 ; write_ptr=DLOG_4CH_buff1
MOVL XAR6,#POS_TRIG_S1
MOVL *--XAR4,XAR6 ; task=POS_TRIG_S2
MOV AL,*+XAR5[6] ; ACC=size
MOV *+XAR5[3],AL ; cntr=size
DL_EXIT:
LRETR