summaryrefslogtreecommitdiffstats
path: root/tests/tc100_instructions/insn_SA.awl
blob: a9caf6cd6191a64b020e26be73668708699f34e4 (plain)
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
ORGANIZATION_BLOCK OB 1
BEGIN

	// Start timer and let it expire
	__STWRST
	L		0
	SA		T 10
	SET
	R		T 10
	U		T 10
	__ASSERT==	__STW VKE,	0
	SET
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT==	__ACCU 1,	0
	__SLEEP		101
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT==	__ACCU 1,	0


	// Start timer and reset VKE
	__STWRST
	L		0
	SA		T 10
	SET
	R		T 10
	U		T 10
	__ASSERT==	__STW VKE,	0
	SET
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT==	__ACCU 1,	0
	__SLEEP		101
	L		T 10
	__ASSERT==	__ACCU 1,	0
	CLR
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT>=	__ACCU 1,	5
	__SLEEP		101
	U		T 10
	__ASSERT==	__STW VKE,	0
	L		T 10
	__ASSERT==	__ACCU 1,	0


	// Retrigger
	__STWRST
	L		0
	SA		T 10
	SET
	R		T 10
	U		T 10
	__ASSERT==	__STW VKE,	0
	SET
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT==	__ACCU 1,	0
	CLR
	L		W#16#0010
	SA		T 10
	__SLEEP		20
	SET
	SA		T 10
	L		T 10
	__ASSERT>=	__ACCU 1,	2
	__SLEEP		101
	L		T 10
	__ASSERT==	__ACCU 1,	__ACCU 2


	// Reset signal
	__STWRST
	L		0
	SA		T 10
	SET
	R		T 10
	U		T 10
	__ASSERT==	__STW VKE,	0
	SET
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT==	__ACCU 1,	0
	__ASSERT==	__ACCU 1,	0
	CLR
	L		W#16#0010
	SA		T 10
	U		T 10
	__ASSERT==	__STW VKE,	1
	L		T 10
	__ASSERT>=	__ACCU 1,	5
	SET
	R		T 10
	U		T 10
	__ASSERT==	__STW VKE,	0
	L		T 10
	__ASSERT==	__ACCU 1,	0
	__SLEEP		101
	U		T 10
	__ASSERT==	__STW VKE,	0
	L		T 10
	__ASSERT==	__ACCU 1,	0


	// Test timer parameter
	AUF		DB 1
	L		DBW 0
	__ASSERT==	__ACCU 1,	24
	CALL FB 1, DB 1 (
		TIMER_VAR	:= T 42
	)


	CALL SFC 46 // STOP CPU
END_ORGANIZATION_BLOCK


FUNCTION_BLOCK FB 1
	VAR_INPUT
		TIMER_VAR	: TIMER;
	END_VAR
BEGIN
	L		DIW 0
	__ASSERT==	__ACCU 1,	42
	L		#TIMER_VAR
	__ASSERT==	__ACCU 1,	0
	U		#TIMER_VAR
	__ASSERT==	__STW VKE,	0

	SA		#TIMER_VAR
END_FUNCTION_BLOCK


DATA_BLOCK DB 1
	FB 1
BEGIN
	TIMER_VAR	:= T 24;
END_DATA_BLOCK
bues.ch cgit interface