Revision 238

View differences:

branch/vilain_sebastien/Emb_App.tws
8 8
[BREAKPOINTS]
9 9
[OPEN_WORKSPACE_FILES]
10 10
"E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 
11
"E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 
11 12
"E:\tp_info6_2018_vilain_sebastien\Emb_App\conf_noyau.cfg" 
12 13
"E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" 
13 14
"E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 
......
18 19
"E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" -8 -30 1596 539 1 1 
19 20
"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 0 
20 21
"E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 75 75 1430 351 0 3 
22
"E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 125 125 1430 351 0 5 
21 23
[LOADED_PROJECTS]
22 24
"EmbM32C87App" 
23 25
[END]
branch/vilain_sebastien/Emb_App/SessionM32C_E8a_system.hsf
141 141
"{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
142 142
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
143 143
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
144
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
144
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000044" 
145 145
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
146 146
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
147 147
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
......
149 149
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
150 150
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
151 151
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0574" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0577" 
153 153
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000AE0" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000081A" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000E08" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000830" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
157 157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000044" 
158 158
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
159 159
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
......
173 173
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
174 174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "000000000000000A" 
175 175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000B16" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000E2C" 
177 177
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
178 178
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
179 179
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
......
205 205
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth2" "120" 
206 206
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth3" "200" 
207 207
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
208
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "erreur, 1, 0, P, Col, Dec, MA" 
208
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "erreur, 10, 0, P, Col, Hex, N" 
209 209
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
210 210
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "dist, 1, 0, P, Col, Dec, MA" 
211 211
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "2" 
212
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "angle_roues, 1, 0, P, Col, Dec, MA" 
213
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
214
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "rampe, 1, 0, P, Col, Dec, MA" 
215
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
216
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "lecture, 1, 0, P, Col, Hex, MA" 
217
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
218
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
213 219
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
214 220
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
215 221
"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
......
313 319
[WINDOW_Z_ORDER]
314 320
"E:\tp_info6_2018_vilain_sebastien\Emb_App\crt0mr.a30" 
315 321
"E:\tp_info6_2018_vilain_sebastien\Emb_App\programme_principal_etud.c" 
322
"E:\tp_info6_2018_vilain_sebastien\bsp\uart0.c" 
316 323
"E:\tp_info6_2018_vilain_sebastien\Emb_App\conf_noyau.cfg" 
317 324
"E:\tp_info6_2018_vilain_sebastien\Emb_App\Debug\mr308.inc" 
318 325
"E:\tp_info6_2018_vilain_sebastien\bsp\periph.c" 
......
362 369
[FLASH_DETAILS]
363 370
"" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
364 371
[BREAKPOINTS]
365
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 89664616 1 "{00000000-0000-0000-C000-000000000046}" "" 
372
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 99232872 1 "{00000000-0000-0000-C000-000000000046}" "" 
366 373
[END]
branch/vilain_sebastien/Emb_App/programme_principal_etud.c
124 124
void commande_angle_roues(short angle_roues);
125 125
short lecture_angle();
126 126
short lecture_telemetre();
127
short lecture_capteur();
127 128
void commande_vitesse(short vitesse);
128
void choix_circuit(int i);
129
void init_vitesse(short vitesse);
129 130
short consigne_angle = 450;
130
short erreur;
131
short vitesse = 120;
132
short consigne_telemetre = 714;
131
short consigne_telemetre = 705;
133 132
FLGPTN flag;
134 133
short dist;
134
short angle_roues;
135
int rampe = 0;
136
short lecture;
135 137

  
136 138
void main()
137 139
{
......
139 141
	ports_mcu();
140 142
    lcd_init();
141 143
	periph_init();
142
	periph_nom("#Test*");
144
	periph_nom("#Seb*");
143 145

  
144 146
    can_init();
145 147
    clavier_init(1);
146 148
	capture_init();
147 149
	
148 150
	periph[ADDR('R')].ev=0x01;
151
	periph[ADDR('U')].ev=0x02;
152
	periph[ADDR('C')].ev=0x03;
149 153
	
150 154
	sta_cyc(ID_acqui);
151 155
	sta_tsk(ID_periph_rx);
152 156
	sta_tsk(ID_asserv0);
153 157
	sta_tsk(ID_asserv1);
158
	sta_tsk(ID_commande_capteur);
154 159

  
155
	commande_vitesse(35);
160
	init_vitesse(45);
156 161
	
157 162
    while(1)
158 163
    {
......
180 185

  
181 186
short lecture_angle()
182 187
{
183
	CanFrame requete, reponse;
188
	CanFrame requete;
184 189
	
185 190
	requete.data.id = 'R';
186 191
	requete.data.rtr = 1;
......
198 203
	{
199 204
		erreur = K*(consigne_angle-lecture_angle());
200 205
		commande_tourelle(erreur);
201
		dly_tsk(98);
206
		dly_tsk(25);
202 207
	}
203 208
}
204 209

  
......
214 219

  
215 220
short lecture_telemetre()
216 221
{
217
	CanFrame requete, reponse;
222
	CanFrame requete;
218 223
	
219 224
	requete.data.id = 'U';
220 225
	requete.data.rtr = 1;
221 226
	snd_dtq(CanTx, requete.msg);
222
	wai_flg (ev_periph,0x01,TWF_ORW,&flag);
223
	clr_flg(ev_periph,~0x01);
227
	wai_flg (ev_periph,0x02,TWF_ORW,&flag);
228
	clr_flg(ev_periph,~0x02);
224 229
	return (periph[ADDR('U')].val);
225 230
}
226 231

  
227 232
void asserv1()
228 233
{
229
	int K = 1;
234
	int K = 2;
230 235
	short erreur;
231 236
	short ancien_dist;
232 237
	while(1)
233 238
	{
234
		ancien_dist = dist;
235
		dist = lecture_telemetre();
236
		if(dist >= 1000)
239
		if (rampe == 0)
237 240
		{
238
			dist = ancien_dist;
241
			ancien_dist = dist;
242
			dist = lecture_telemetre();
243
			if((dist >= 2000)||(dist <= -2000))
244
			{
245
				dist = ancien_dist;
246
			}
247
			erreur = K*(consigne_telemetre-dist);
248
			angle_roues = -erreur;
249
			commande_angle_roues(-erreur);
239 250
		}
240
		erreur = K*(consigne_telemetre-dist);
241
		commande_angle_roues(-erreur);
242
		dly_tsk(98);
251
		dly_tsk(5);
243 252
	}
244 253
}
245 254

  
246 255
void commande_vitesse(short vitesse)
256
{	
257
	CanFrame comm;
258
	
259
	comm.data.id = 'V';
260
	comm.data.rtr = 0;
261
	comm.data.val=vitesse;
262
	snd_dtq(CanTx, comm.msg);
263
}
264

  
265
void init_vitesse(short vitesse)
247 266
{
267
	dly_tsk(3000);
268
	commande_vitesse(vitesse);
269
}
270

  
271
short lecture_capteur()
272
{
248 273
	CanFrame requete;
249 274
	
250
	dly_tsk(3000);
251
	requete.data.id = 'V';
252
	requete.data.rtr = 0;
253
	requete.data.val=vitesse;
275
	requete.data.id = 'C';
276
	requete.data.rtr = 1;
254 277
	snd_dtq(CanTx, requete.msg);
278
	wai_flg (ev_periph,0x03,TWF_ORW,&flag);
279
	clr_flg(ev_periph,~0x03);
280
	return (periph[ADDR('C')].val);
281
}
282

  
283
void commande_capteur()
284
{
285
	while(1)
286
	{
287
		lecture = lecture_capteur();
288
		if((lecture & 0xFF00) == 0x6200) //bleu
289
		{
290
			rampe = 1;
291
		}
292
		if ((lecture & 0xFF00) == 0x7600) //vert
293
		{
294
			rampe = 0;
295
			commande_vitesse(20);
296
		}
297
		if ((lecture & 0xFF00) == 0x6a00) //jaune
298
		{
299
			rampe = 0;
300
		}
301
		if ((lecture & 0xFF00) == 0x5604)
302
		{
303
			commande_vitesse(45);
304
		}
305
		if ((lecture & 0xFF00) == 0x7200) //rouge
306
		{
307
			consigne_telemetre = 600;
308
		}
309
		if ((lecture & 0xFF00) == 0x6300) //cyan
310
		{
311
			consigne_telemetre = 705;
312
		}
313
		dly_tsk(100);
314
	}
255 315
}
branch/vilain_sebastien/Emb_App/conf_noyau.cfg
2 2
//
3 3
//    kernel.cfg : building file for MR308 Ver.4.00
4 4
//
5
//    Generated by M3T-MR308 GUI Configurator at 2018/12/03 16:28:30
5
//    Generated by M3T-MR308 GUI Configurator at 2018/12/12 15:16:07
6 6
//
7 7
////////////////////////////////////////////////////////////////////////////////
8 8

  
......
20 20

  
21 21
// max definition
22 22
maxdefine{
23
	max_task	= 5;
23
	max_task	= 6;
24 24
	max_flag	= 3;
25 25
	max_dtq	= 2;
26 26
	max_cyh	= 1;
......
75 75
	name	= ID_asserv1;
76 76
	stack_size	= 256;
77 77
	stack_section	= stack;
78
	priority	= 8;
79
	initial_start	= OFF;
80
	exinf	= 0x0;
81
};
82
task[]{
83
	entry_address	= commande_capteur();
84
	name	= ID_commande_capteur;
85
	stack_size	= 256;
86
	stack_section	= stack;
78 87
	priority	= 1;
79 88
	initial_start	= OFF;
80 89
	exinf	= 0x0;

Also available in: Unified diff