Index: branch/diagne/Emb_App.tws
===================================================================
--- branch/diagne/Emb_App.tws	(revision 380)
+++ branch/diagne/Emb_App.tws	(revision 381)
@@ -11,15 +11,13 @@
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\Debug\mr308.inc" 100 100 1054 351 0 4 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\conf_noyau.cfg" 125 125 1054 351 0 1 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\crt0mr.a30" -8 -30 1220 539 1 2 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\programme_principal_etud.c" 0 0 1220 539 0 0 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\periph.c" 150 150 1054 351 0 6 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\uart0.c" 75 75 1054 351 0 3 
+"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\conf_noyau.cfg" 25 25 1054 351 0 1 
+"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\crt0mr.a30" -8 -30 1061 539 1 2 
+"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\programme_principal_etud.c" 0 0 1061 539 0 0 
+"E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\periph.c" 25 25 895 351 0 4 
+"E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\uart0.c" 0 0 895 351 0 3 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/diagne/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/diagne/Emb_App/SessionM32C_E8a_system.ini	(revision 380)
+++ branch/diagne/Emb_App/SessionM32C_E8a_system.ini	(revision 381)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0016
+RESET=ff0014
Index: branch/diagne/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/diagne/Emb_App/SessionM32C_E8a_system.hsf	(revision 380)
+++ branch/diagne/Emb_App/SessionM32C_E8a_system.hsf	(revision 381)
@@ -141,20 +141,20 @@
 "{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" "0000000000004044" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000000" 
 "{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" 
 "{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" "0000000000FF0582" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000BF8" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000828" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000001" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004044" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_15" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0016" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000700" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000000" 
 "{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" 
@@ -169,12 +169,12 @@
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_31" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_32" "0000000000000000" 
 "{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_34" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_35" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "000000000000000A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000C24" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_7" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_COUNT" "36" 
@@ -211,7 +211,11 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "longueur, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "3" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "distance, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "capt, 1, 0, P, Col, Hex, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "5" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -281,14 +285,14 @@
 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 3 "0.08" 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 125 125 1054 351 10 0 "" "0.0" 
+"{WK_00000001_CmdLine}" "WINDOW" 59422 0 3 "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 125 125 1054 351 9 0 "" "0.0" 
 "{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 0 "0.13" 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" 
 "{WK_00000001_OUTPUT}" "WINDOW" 59422 0 2 "0.79" 365 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
 "{WK_00000001_PDMR}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.08" 365 0 0 350 200 18 0 "47300|47301|47302|47303|47304|47305|47314|47306|47307|47308|47311|47312|47313|42211|42509|42303" "0.0" 
 "{WK_00000001_REGISTERS}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59421 0 0 "1.00" 236 0 0 350 200 2065 0 "" "0.0" 
-"{WK_00000001_WATCH}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59421 0 0 "1.00" 369 2 103 350 97 18 0 "32781|32783|<<separator>>|32771|32772|32773|<<separator>>|32786|<<separator>>|32810|32811" "0.0" 
+"{WK_00000001_WATCH}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59421 0 0 "1.00" 528 2 103 350 97 18 0 "32781|32783|<<separator>>|32771|32772|32773|<<separator>>|32786|<<separator>>|32810|32811" "0.0" 
 "{WK_00000002_WORKSPACE}" "WINDOW" 59420 0 0 "1.00" 308 0 0 350 200 18 0 "" "0.0" 
 "{WK_TB00000001_STANDARD}" "TOOLBAR 0" 59419 0 2 "0.00" 0 0 0 0 0 18 0 "" "0.0" 
 "{WK_TB00000002_EDITOR}" "TOOLBAR 0" 59419 0 0 "0.00" 0 0 0 0 0 18 0 "" "0.0" 
@@ -317,8 +321,6 @@
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\uart0.c" 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\bsp\periph.c" 
-"E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\Debug\Disassembly" 
 "E:\tp_info6_2018_diagne\tp_info6\tp_info6\Emb_App\Debug\mr308.inc" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
@@ -366,5 +368,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 99088656 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 100013840 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/diagne/Emb_App/programme_principal_etud.c
===================================================================
--- branch/diagne/Emb_App/programme_principal_etud.c	(revision 380)
+++ branch/diagne/Emb_App/programme_principal_etud.c	(revision 381)
@@ -121,10 +121,16 @@
 //				correspondant au nom du véhicule si le nom se termine par '*'
 
 
+
 short alpha;
-short vitesse, longueur;
-short distance, new_distance, capt;
-
+short vitesse;
+short longueur;
+short distance;
+short new_distance;
+short capt;
+short piste;
+
+
 void Asserv0(){	
 	
 		CanFrame req,reponse,comm;
@@ -146,7 +152,7 @@
 			comm.data.rtr=0;
 	 		comm.data.val=(450-alpha); // Pour un gain de 1, on regule pour avoir 45degrés (angle du telemetre)
 			snd_dtq(CanTx,comm.msg);
-			dly_tsk(100);
+			dly_tsk(10);
 		}	
 		
 }
@@ -164,13 +170,27 @@
 		snd_dtq(CanTx,req.msg);
 		wai_flg(ev_periph, 0x03, TWF_ANDW,&flag);
 		capt=periph[ADDR('C')].val;
-		dly_tsk(100);
+		dly_tsk(20);
 	}
 }
 
+void num_piste() //permet de savoir sur quel piste on est
+{
+	CanFrame req;
+	UINT flag;
+	while(1)
+	{
+		req.data.id='M';
+		req.data.rtr=1;					 //Lecture de la valeur du capteur
+		periph[ADDR('M')].ev=0x04;
+		snd_dtq(CanTx,req.msg);
+		wai_flg(ev_periph, 0x04, TWF_ANDW,&flag);
+		piste=(periph[ADDR('M')].val)&0x00ff;
+		dly_tsk(20);
+	}
+}
 		
 
-
 void regulation_roue(){
 		CanFrame req,reponse,comm;
 		UINT flag;	
@@ -195,57 +215,68 @@
 	 		
 			//Pour eviter les trous de la piste bleue et garder le vehicule au milieu de la piste
 			
-				if (capt=0x5603) //valeur du 3eme capteur vert
-				{
-					new_distance=715;
-					
+			if (piste==0x0007)
+			{
+				
+				if(capt==0x7604){
+				
+				comm.data.val=0;
+				snd_dtq(CanTx,comm.msg);
 				}
-				
-				else
-				{
+				else{
+						
 					if (distance >1000)//On compare la distance mesurée par le telemtetre
 						
 					{						
-							new_distance=715;
+							new_distance=710;
+							
 					}
 					
-					else {
-				
-							new_distance=distance;
-							
-						}
-				}
-				
-				comm.data.val=1*(new_distance-715); //	On la garde bien au milieu de la piste
-				
-				snd_dtq(CanTx,comm.msg);
-				dly_tsk(100);
+					else new_distance=distance;
+						comm.data.val=1*(new_distance-710); //	On la garde bien au milieu de la piste
+						snd_dtq(CanTx,comm.msg);}
+					   	dly_tsk(10);
+					}
+		else
+		{
+			comm.data.val=(450-distance);
+			snd_dtq(CanTx,comm.msg);
 		}
+
+			
 }
+}
 
-
-void roue_piste_rouge()
-{
 	
-}
 void Avancer(){
 	dly_tsk(6000);
 	while(1)
-	{
-		CanFrame req;
-		req.data.id='V';
-		req.data.rtr=0;
-		if (capt=0x5603)
+	{ if (piste==0x0007)
+		{
+			CanFrame req;
+			req.data.id='V';
+			req.data.rtr=0;
+			if (capt==0x7604)
 			{
-			req.data.val=45;
+ 				req.data.val=45;
+				snd_dtq(CanTx,req.msg);
 			}
-		else
-			{		
-			req.data.val=15;
+			else{	
+				if (capt==0x4203)
+				{
+ 				req.data.val=7;
+				snd_dtq(CanTx,req.msg);
+				}	
+				else
+				{		
+				req.data.val=30;
+				snd_dtq(CanTx,req.msg);
+				}
 			}
-			snd_dtq(CanTx,req.msg);
-	}
-}
+		}
+	
+		
+} }
 
 	
 void main()
@@ -254,7 +285,7 @@
 	ports_mcu();
     lcd_init();
 	periph_init();
-	periph_nom("#AutoTest*");
+	periph_nom("#Coumba*");
 
 
     can_init();
@@ -272,6 +303,7 @@
  	sta_tsk(ID_Avancer);
 	sta_tsk(ID_roue);
 	sta_tsk(ID_capteur);
+	sta_tsk(ID_piste);
 //	sta_tsk(ID_roue_rouge);
 	
     while(1)
Index: branch/diagne/Emb_App/conf_noyau.cfg
===================================================================
--- branch/diagne/Emb_App/conf_noyau.cfg	(revision 380)
+++ branch/diagne/Emb_App/conf_noyau.cfg	(revision 381)
@@ -93,18 +93,19 @@
 };
 
 task[]{
-	entry_address	= Capteur();
-	name	= ID_capteur;
+	entry_address	= num_piste();
+	name	= ID_piste;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	=8;
+	priority	= 7;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
 
+
 task[]{
-	entry_address	= roue_piste_rouge();
-	name	= ID_roue_rouge;
+	entry_address	= Capteur();
+	name	= ID_capteur;
 	stack_size	= 256;
 	stack_section	= stack;
 	priority	=8;
@@ -112,6 +113,7 @@
 	exinf	= 0x0;
 };
 
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
Index: branch/diagne/Emb_App/EmbM32C87App.tps
===================================================================
--- branch/diagne/Emb_App/EmbM32C87App.tps	(revision 380)
+++ branch/diagne/Emb_App/EmbM32C87App.tps	(revision 381)
@@ -18,7 +18,7 @@
 "SessionM32C_E8a_system" 
 [GENERAL_DATA_PROJECT]
 [GENERAL_DATA_CONFIGURATION_Debug]
-"PROJECT_FILES_MODIFIED_DATA_TAG" "TRUE" 
+"PROJECT_FILES_MODIFIED_DATA_TAG" "FALSE" 
 [SESSIONS_Debug]
 "DefaultSession" 
 "SessionM32C_E8a_system" 
Index: branch/diagne/bsp/periph.c
===================================================================
--- branch/diagne/bsp/periph.c	(revision 380)
+++ branch/diagne/bsp/periph.c	(revision 381)
@@ -167,7 +167,7 @@
 				periph[c].val=msg.data.val;
 				periph[c].maj++;
 				if (periph[c].ev)
-					set_flg(ev_periph,periph[c].ev);				
+				set_flg(ev_periph,periph[c].ev);				
 				continue;
 			}
 		}
