-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGPT2.C
executable file
·209 lines (140 loc) · 6.35 KB
/
GPT2.C
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//****************************************************************************
// @Module General Purpose Timer Unit (GPT2)
// @Filename GPT2.C
// @Project test3.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC2267M-104F80
//
// @Compiler Keil
//
// @Codegenerator 2.0
//
// @Description This file contains functions that use the GPT2 module.
//
//----------------------------------------------------------------------------
// @Date 2018/11/1 16:59:45
//
//****************************************************************************
// USER CODE BEGIN (GPT2_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (GPT2_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (GPT2_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (GPT2_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (GPT2_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (GPT2_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (GPT2_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (GPT2_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (GPT2_General,9)
// USER CODE END
//****************************************************************************
// @Function void GPT2_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the GPT2 function
// library. It is assumed that the SFRs used by this library
// are in reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2018/11/1
//
//****************************************************************************
// USER CODE BEGIN (Init,1)
// USER CODE END
void GPT2_vInit(void)
{
// USER CODE BEGIN (Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of Timer Block Prescaler 1:
/// -----------------------------------------------------------------------
GPT12E_KSCCFG = 0x0003; // Module Enable
_nop_(); // one cycle delay
_nop_(); // one cycle delay
/// -----------------------------------------------------------------------
/// Configuration of Timer Block Prescaler 2:
/// -----------------------------------------------------------------------
/// - prescaler for timer block 2 is 4
/// -----------------------------------------------------------------------
/// Configuration of the GPT2 Core Timer 5:
/// -----------------------------------------------------------------------
/// - timer 5 works in timer mode
/// - prescaler factor is 4
/// - up/down control bit is reset
/// - external up/down control is disabled
/// - timer 5 run bit is reset
/// - timer 5 remote control is disabled
GPT12E_T5CON = 0x0000; // load timer 5 control register
GPT12E_T5 = 0x0000; // load timer 5 register
/// -----------------------------------------------------------------------
/// Configuration of the GPT2 Core Timer 6:
/// -----------------------------------------------------------------------
/// - timer 6 works in timer mode
/// - prescaler factor is 4
/// - up/down control bit is reset
/// - external up/down control is disabled
/// - alternate output function T6OUT (P6.2) is disabled
/// - alternate output function T6OUT (P7.0) is disabled
/// - timer 6 output toggle latch (T6OTL) is set to 0
/// - timer 6 run bit is reset
/// - timer 6 is not cleared on a capture
GPT12E_T6CON = 0x0000; // load timer 6 control register
GPT12E_T6 = 0x0000; // load timer 6 register
/// -----------------------------------------------------------------------
/// Configuration of the GPT2 CAPREL:
/// -----------------------------------------------------------------------
/// - capture T5 into CAPREL is disabled
/// - capture trigger from pin CAPIN
/// - capure is disabled
/// - timer 5 is not cleared on a capture
/// - timer 5 is just captured without any correction
GPT12E_T5CON |= 0x0000; // load timer 5 control register
GPT12E_CAPREL = 0x0000; // load CAPREL register
/// -----------------------------------------------------------------------
/// Configuration of the used GPT2 Port Pins:
/// -----------------------------------------------------------------------
/// -----------------------------------------------------------------------
/// Configuration of the used GPT2 Interrupts:
/// -----------------------------------------------------------------------
// USER CODE BEGIN (GPT2_Function,3)
// USER CODE END
} // End of function GPT2_viCAPREL
// USER CODE BEGIN (GPT2_General,10)
// USER CODE END