Index: branch/fichot/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/fichot/Emb_App/SessionM32C_E8a_system.ini	(revision 348)
+++ branch/fichot/Emb_App/SessionM32C_E8a_system.ini	(revision 349)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff001c
+RESET=ff001e
Index: branch/fichot/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/fichot/Emb_App/SessionM32C_E8a_system.hsf	(revision 348)
+++ branch/fichot/Emb_App/SessionM32C_E8a_system.hsf	(revision 349)
@@ -141,8 +141,8 @@
 "{55384715-F881-421C-A548-D7D1ABE158E1}PDMRWndInstanceKey0" "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_DENORMAL_MODE" "0" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_EVAL_ROUND_MODE" "0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000001" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_12" "0000000000000000" 
@@ -149,12 +149,12 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_13" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_14" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000512" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF3116" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0578" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000009FC" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "00000000000000C0" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000BE8" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000818" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000004" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000044" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_21" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_22" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_23" "0000000000000000" 
@@ -171,9 +171,9 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_33" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_34" "000000000000036A" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000004" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000550055" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000009FC" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "000000000000000A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000C14" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
@@ -279,7 +279,7 @@
 0 
 [WINDOW_POSITION_STATE_DATA_VD1]
 "Help" "TOOLBAR 0" 59419 2 4 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
-"{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" 
+"{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" 
 "{WK_00000001_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "0.0" 
 "{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" 
 "{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,12 +311,14 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_fichot\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_fichot\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_fichot\Emb_App\Debug\mr308.inc" 
+"E:\tp_info6_2018_fichot\bsp\clavier.c" 
+"E:\tp_info6_2018_fichot\bsp\uart0.c" 
 "E:\tp_info6_2018_fichot\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_2018_fichot\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_fichot\bsp\periph.c" 
 "E:\tp_info6_2018_fichot\bsp\carte_m32.h" 
-"E:\tp_info6_2018_fichot\bsp\clavier.c" 
 "E:\tp_info6_2018_fichot\bsp\carte_io.h" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
@@ -364,5 +366,5 @@
 [FLASH_DETAILS]
 "" 0 0 "" 0 "" 0 0 "" 0 0 0 0 0 0 0 "" "" "" "" "" 
 [BREAKPOINTS]
-"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 92734744 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 95549384 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/fichot/Emb_App/programme_principal_etud.c
===================================================================
--- branch/fichot/Emb_App/programme_principal_etud.c	(revision 348)
+++ branch/fichot/Emb_App/programme_principal_etud.c	(revision 349)
@@ -121,42 +121,46 @@
 //				correspondant au nom du véhicule si le nom se termine par '*'
 
 
-int k=5;
-int k2=1;
-int vitesse = 30;
+int k1=4;
+int k2=2;
+UINT flag;
+unsigned short capt=0;
+unsigned short stop = 0;
+unsigned short vitesse;
+int num_piste;                                                
+int rpiste;
 
+CanFrame vit_roue; 
 
-
-CanFrame vit_roue; //canal de commande de la vitesse
-
-void demarrer()
+void demarrer(vitesse)
 {
 	vit_roue.data.id='V'; 
 	vit_roue.data.rtr=0; 
 	vit_roue.data.val=vitesse;
 	snd_dtq (CanTx,vit_roue.msg);
-	dly_tsk(100);
+	
 }
 
 void asserv_tourelle()
 {
         CanFrame comm;
+		UINT flag;
 		short angle;
-		CanFrame req, reponse;
-                        
-       	while(1){      
-	        req.data.id = 'R';                                
-	        req.data.rtr = 1;       
-			
-			snd_dtq(CanTx, req.msg);
-                
+		short consigne = 450;
+		CanFrame req;
+        req.data.id = 'R';                              
+	    req.data.rtr = 1;            
+       	while(1){           
+			periph[ADDR('R')].ev=0X01;
+            snd_dtq(CanTx, req.msg);
+            wai_flg(ev_periph,0X01,TWF_ANDW, &flag);
 			angle = periph[ADDR('R')].val; //réponse de l'angle
 		
 			comm.data.id = 'T';                                                                
 	        comm.data.rtr = 0;                                                                 
-	        comm.data.val = k*(450 - angle);        
+	        comm.data.val = k1*(consigne - angle);      
 	        snd_dtq(CanTx, comm.msg);
-			dly_tsk(100);
+			dly_tsk(5);
 		}
 }
 
@@ -164,37 +168,87 @@
 {
         CanFrame comm;
 		CanFrame req, reponse;
-		unsigned short consigne = 710;
-		unsigned short distance;
+		UINT flag;
+		short consigne = 710;
+		short distance;
 		short rot;
-               
+        req.data.id = 'U';                               
+		req.data.rtr = 1;  
 		
-     	while(1){
-			
-		        req.data.id = 'U';                                
-		        req.data.rtr = 1;       
-		
-				snd_dtq(CanTx, req.msg);
-		        periph[ADDR('U')].val;         
-					
+     	while(1){     
+				periph[ADDR('U')].ev=0X02;
+				snd_dtq(CanTx, req.msg);        
+				wai_flg(ev_periph,0X02,TWF_ANDW, &flag);
 				distance = periph[ADDR('U')].val; 
-				rot = k2*(distance-consigne);
-				if (distance <= 1000 && distance >= 400 )
-	                {
-	                	comm.data.id='D'; comm.data.rtr=0; comm.data.val=rot;
-	                	snd_dtq (CanTx,comm.msg);
-	                }
-        		else
-                {
-                	comm.data.id='D'; comm.data.rtr=0; comm.data.val=0;
-                	snd_dtq (CanTx,comm.msg);
-				}                      
+				
+				if(distance>1500 || stop==1){
+                 	comm.data.id='D';
+                    comm.data.rtr = 0;
+                    comm.data.val = 0;
+                    dly_tsk(10);
+				}
+				else{
+                                        
+                	req.data.id = 'U';
+                    req.data.rtr = 1;
+                    snd_dtq(CanTx, req.msg);
+                    distance=periph[ADDR('U')].val; 
+                    //Asservissement
+                    rot=k2*(distance-consigne);
+                    comm.data.id='D';
+                    comm.data.rtr = 0;
+                    comm.data.val = rot;
+        
+                   snd_dtq(CanTx,comm.msg);
+                   dly_tsk(10);
+				}            
 				dly_tsk(10);
-				
-				
 		}
 }
 
+
+void capteur(){
+        CanFrame req;
+        CanFrame comm;
+        while (1){
+			stop = 0;
+        	req.data.id = 'C';
+            req.data.rtr = 1;
+            snd_dtq(CanTx, req.msg);
+            capt=periph[ADDR('C')].val;
+			stop = 0;
+            while(capt==0x7620){
+				stop = 1;
+				req.data.id = 'C';
+                req.data.rtr = 1;
+                snd_dtq(CanTx, req.msg);
+                capt=periph[ADDR('C')].val;
+                demarrer(50);
+                comm.data.id='D';
+                comm.data.rtr = 0;
+                comm.data.val = 0;
+                snd_dtq(CanTx,comm.msg);
+				dly_tsk(1000);
+			} 
+         dly_tsk(10);
+        }
+}
+				
+void piste(){
+        CanFrame requete;
+        UINT flag;
+        
+        requete.data.id = 'M';
+        requete.data.rtr = 1;        
+        periph[ADDR('M')].ev = 0x04;
+        snd_dtq(CanTx, requete.msg);
+        wai_flg(ev_periph, 0x04, TWF_ANDW, &flag); 
+        num_piste = periph[ADDR('M')].val;      
+        rpiste = num_piste & 0x00ff;        
+}				
+			
+
+
 void main()
 {        
     ports_mcu();
@@ -210,10 +264,13 @@
 	sta_tsk(ID_asserv_tourelle);
 	dly_tsk(1000);
 	sta_tsk(ID_asserv2);
+	sta_tsk(ID_capteur);
 	dly_tsk(2000);
+	demarrer(30);
 	while(1){
-		demarrer();
-        }
+		
+        dly_tsk(2000);	
+    }
          
 }
 void acqui()
Index: branch/fichot/Emb_App/conf_noyau.cfg
===================================================================
--- branch/fichot/Emb_App/conf_noyau.cfg	(revision 348)
+++ branch/fichot/Emb_App/conf_noyau.cfg	(revision 349)
@@ -2,7 +2,7 @@
 //
 //    kernel.cfg : building file for MR308 Ver.4.00
 //
-//    Generated by M3T-MR308 GUI Configurator at 2018/12/14 14:41:44
+//    Generated by M3T-MR308 GUI Configurator at 2018/12/19 15:14:55
 //
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -9,7 +9,7 @@
 // system definition
 system{
 	stack_size	= 256;
-	priority	= 10;
+	priority	= 11;
 	system_IPL	 = 4;
 	message_pri	 = 1;
 	timeout	 = YES;
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 5;
+	max_task	= 6;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 1;
@@ -79,6 +79,15 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+task[]{
+	entry_address	= capteur();
+	name	= ID_capteur;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 11;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
 
 flag[]{
 	name	= ev_bus_fin_tr;
Index: branch/fichot/Emb_App/conf_noyau.hcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
