Revision 349

View differences:

branch/fichot/Emb_App/SessionM32C_E8a_system.ini
25 25
[Target]
26 26
M32C E8a SYSTEM=Renesas Communications
27 27
[USER_DATA]
28
RESET=ff001c
28
RESET=ff001e
branch/fichot/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" "0000000000000001" 
145
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
144
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
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" 
148 148
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "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" "0000000000FF3116" 
152
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0578" 
153 153
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000009FC" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000800" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "00000000000000C0" 
157
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
154
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000BE8" 
155
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000818" 
156
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000004" 
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" 
160 160
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
......
171 171
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
172 172
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
173 173
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000004" 
175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000550055" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000009FC" 
174
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "000000000000000A" 
175
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
176
"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000C14" 
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" 
......
279 279
0 
280 280
[WINDOW_POSITION_STATE_DATA_VD1]
281 281
"Help" "TOOLBAR 0" 59419 2 4 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
282
"{WK_00000001_CmdLine}" "WINDOW" 59422 0 1 "0.08" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
282
"{WK_00000001_CmdLine}" "WINDOW" 59422 0 1 "0.07" 365 0 0 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
283 283
"{WK_00000001_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "0.0" 
284 284
"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.11" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
285 285
"{WK_00000001_MEMORY}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.23" 365 2 -1 350 200 2065 0 "42202|42203|42204|42233|<<separator>>|42206|42205|42230|42229|42207|<<separator>>|42208|42209|42210|49076|42228|42227|<<separator>>|42231|42232|42234|42235|<<separator>>|42211|<<separator>>|32796|32797" "0.0" 
......
311 311
[WINDOW_POSITION_STATE_DATA_VD3]
312 312
[WINDOW_POSITION_STATE_DATA_VD4]
313 313
[WINDOW_Z_ORDER]
314
"E:\tp_info6_2018_fichot\Emb_App\crt0mr.a30" 
314 315
"E:\tp_info6_2018_fichot\Emb_App\programme_principal_etud.c" 
316
"E:\tp_info6_2018_fichot\Emb_App\Debug\mr308.inc" 
317
"E:\tp_info6_2018_fichot\bsp\clavier.c" 
318
"E:\tp_info6_2018_fichot\bsp\uart0.c" 
315 319
"E:\tp_info6_2018_fichot\Emb_App\conf_noyau.cfg" 
316
"E:\tp_info6_2018_fichot\Emb_App\crt0mr.a30" 
317 320
"E:\tp_info6_2018_fichot\bsp\periph.c" 
318 321
"E:\tp_info6_2018_fichot\bsp\carte_m32.h" 
319
"E:\tp_info6_2018_fichot\bsp\clavier.c" 
320 322
"E:\tp_info6_2018_fichot\bsp\carte_io.h" 
321 323
[TARGET_NAME]
322 324
"M32C E8a SYSTEM" "" 0 
......
364 366
[FLASH_DETAILS]
365 367
"" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
366 368
[BREAKPOINTS]
367
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 92734744 1 "{00000000-0000-0000-C000-000000000046}" "" 
369
"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 95549384 1 "{00000000-0000-0000-C000-000000000046}" "" 
368 370
[END]
branch/fichot/Emb_App/programme_principal_etud.c
121 121
//				correspondant au nom du v?hicule si le nom se termine par '*'
122 122

  
123 123

  
124
int k=5;
125
int k2=1;
126
int vitesse = 30;
124
int k1=4;
125
int k2=2;
126
UINT flag;
127
unsigned short capt=0;
128
unsigned short stop = 0;
129
unsigned short vitesse;
130
int num_piste;                                                
131
int rpiste;
127 132

  
133
CanFrame vit_roue; 
128 134

  
129

  
130
CanFrame vit_roue; //canal de commande de la vitesse
131

  
132
void demarrer()
135
void demarrer(vitesse)
133 136
{
134 137
	vit_roue.data.id='V'; 
135 138
	vit_roue.data.rtr=0; 
136 139
	vit_roue.data.val=vitesse;
137 140
	snd_dtq (CanTx,vit_roue.msg);
138
	dly_tsk(100);
141
	
139 142
}
140 143

  
141 144
void asserv_tourelle()
142 145
{
143 146
        CanFrame comm;
147
		UINT flag;
144 148
		short angle;
145
		CanFrame req, reponse;
146
                        
147
       	while(1){      
148
	        req.data.id = 'R';                                
149
	        req.data.rtr = 1;       
150
			
151
			snd_dtq(CanTx, req.msg);
152
                
149
		short consigne = 450;
150
		CanFrame req;
151
        req.data.id = 'R';                              
152
	    req.data.rtr = 1;            
153
       	while(1){           
154
			periph[ADDR('R')].ev=0X01;
155
            snd_dtq(CanTx, req.msg);
156
            wai_flg(ev_periph,0X01,TWF_ANDW, &flag);
153 157
			angle = periph[ADDR('R')].val; //r?ponse de l'angle
154 158
		
155 159
			comm.data.id = 'T';                                                                
156 160
	        comm.data.rtr = 0;                                                                 
157
	        comm.data.val = k*(450 - angle);        
161
	        comm.data.val = k1*(consigne - angle);      
158 162
	        snd_dtq(CanTx, comm.msg);
159
			dly_tsk(100);
163
			dly_tsk(5);
160 164
		}
161 165
}
162 166

  
......
164 168
{
165 169
        CanFrame comm;
166 170
		CanFrame req, reponse;
167
		unsigned short consigne = 710;
168
		unsigned short distance;
171
		UINT flag;
172
		short consigne = 710;
173
		short distance;
169 174
		short rot;
170
               
175
        req.data.id = 'U';                               
176
		req.data.rtr = 1;  
171 177
		
172
     	while(1){
173
			
174
		        req.data.id = 'U';                                
175
		        req.data.rtr = 1;       
176
		
177
				snd_dtq(CanTx, req.msg);
178
		        periph[ADDR('U')].val;         
179
					
178
     	while(1){     
179
				periph[ADDR('U')].ev=0X02;
180
				snd_dtq(CanTx, req.msg);        
181
				wai_flg(ev_periph,0X02,TWF_ANDW, &flag);
180 182
				distance = periph[ADDR('U')].val; 
181
				rot = k2*(distance-consigne);
182
				if (distance <= 1000 && distance >= 400 )
183
	                {
184
	                	comm.data.id='D'; comm.data.rtr=0; comm.data.val=rot;
185
	                	snd_dtq (CanTx,comm.msg);
186
	                }
187
        		else
188
                {
189
                	comm.data.id='D'; comm.data.rtr=0; comm.data.val=0;
190
                	snd_dtq (CanTx,comm.msg);
191
				}                      
183
				
184
				if(distance>1500 || stop==1){
185
                 	comm.data.id='D';
186
                    comm.data.rtr = 0;
187
                    comm.data.val = 0;
188
                    dly_tsk(10);
189
				}
190
				else{
191
                                        
192
                	req.data.id = 'U';
193
                    req.data.rtr = 1;
194
                    snd_dtq(CanTx, req.msg);
195
                    distance=periph[ADDR('U')].val; 
196
                    //Asservissement
197
                    rot=k2*(distance-consigne);
198
                    comm.data.id='D';
199
                    comm.data.rtr = 0;
200
                    comm.data.val = rot;
201
        
202
                   snd_dtq(CanTx,comm.msg);
203
                   dly_tsk(10);
204
				}            
192 205
				dly_tsk(10);
193
				
194
				
195 206
		}
196 207
}
197 208

  
209

  
210
void capteur(){
211
        CanFrame req;
212
        CanFrame comm;
213
        while (1){
214
			stop = 0;
215
        	req.data.id = 'C';
216
            req.data.rtr = 1;
217
            snd_dtq(CanTx, req.msg);
218
            capt=periph[ADDR('C')].val;
219
			stop = 0;
220
            while(capt==0x7620){
221
				stop = 1;
222
				req.data.id = 'C';
223
                req.data.rtr = 1;
224
                snd_dtq(CanTx, req.msg);
225
                capt=periph[ADDR('C')].val;
226
                demarrer(50);
227
                comm.data.id='D';
228
                comm.data.rtr = 0;
229
                comm.data.val = 0;
230
                snd_dtq(CanTx,comm.msg);
231
				dly_tsk(1000);
232
			} 
233
         dly_tsk(10);
234
        }
235
}
236
				
237
void piste(){
238
        CanFrame requete;
239
        UINT flag;
240
        
241
        requete.data.id = 'M';
242
        requete.data.rtr = 1;        
243
        periph[ADDR('M')].ev = 0x04;
244
        snd_dtq(CanTx, requete.msg);
245
        wai_flg(ev_periph, 0x04, TWF_ANDW, &flag); 
246
        num_piste = periph[ADDR('M')].val;      
247
        rpiste = num_piste & 0x00ff;        
248
}				
249
			
250

  
251

  
198 252
void main()
199 253
{        
200 254
    ports_mcu();
......
210 264
	sta_tsk(ID_asserv_tourelle);
211 265
	dly_tsk(1000);
212 266
	sta_tsk(ID_asserv2);
267
	sta_tsk(ID_capteur);
213 268
	dly_tsk(2000);
269
	demarrer(30);
214 270
	while(1){
215
		demarrer();
216
        }
271
		
272
        dly_tsk(2000);	
273
    }
217 274
         
218 275
}
219 276
void acqui()
branch/fichot/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/14 14:41:44
5
//    Generated by M3T-MR308 GUI Configurator at 2018/12/19 15:14:55
6 6
//
7 7
////////////////////////////////////////////////////////////////////////////////
8 8

  
9 9
// system definition
10 10
system{
11 11
	stack_size	= 256;
12
	priority	= 10;
12
	priority	= 11;
13 13
	system_IPL	 = 4;
14 14
	message_pri	 = 1;
15 15
	timeout	 = YES;
......
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;
......
79 79
	initial_start	= OFF;
80 80
	exinf	= 0x0;
81 81
};
82
task[]{
83
	entry_address	= capteur();
84
	name	= ID_capteur;
85
	stack_size	= 256;
86
	stack_section	= stack;
87
	priority	= 11;
88
	initial_start	= OFF;
89
	exinf	= 0x0;
90
};
82 91

  
83 92
flag[]{
84 93
	name	= ev_bus_fin_tr;

Also available in: Unified diff