Index: branch/zemeta/Emb_App.tws
===================================================================
--- branch/zemeta/Emb_App.tws	(revision 390)
+++ branch/zemeta/Emb_App.tws	(revision 391)
@@ -13,11 +13,13 @@
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\uart0.c" 
 "E:\tp_info6_2018_zemeta\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_zemeta\tp_info6\Emb_App\crt0mr.a30" 
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_zemeta\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\Debug\mr308.inc" 25 25 1430 351 0 8 
 "E:\tp_info6_2018_zemeta\tp_info6\Emb_App\conf_noyau.cfg" 1 0 1426 347 0 1 
-"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\crt0mr.a30" -8 -30 1596 539 1 5 
-"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 4 
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\crt0mr.a30" 0 0 1596 539 0 5 
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 4 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\can.c" 50 50 1430 351 0 2 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\dma0.c" 75 75 1430 351 0 3 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\periph.c" 0 0 1430 351 0 7 
Index: branch/zemeta/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/zemeta/Emb_App/SessionM32C_E8a_system.ini	(revision 390)
+++ branch/zemeta/Emb_App/SessionM32C_E8a_system.ini	(revision 391)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0020
+RESET=ff001a
Index: branch/zemeta/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/zemeta/Emb_App/SessionM32C_E8a_system.hsf	(revision 390)
+++ branch/zemeta/Emb_App/SessionM32C_E8a_system.hsf	(revision 391)
@@ -149,7 +149,7 @@
 "{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" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0020" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF001A" 
 "{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" 
@@ -213,15 +213,15 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "angle_reel, 2, 0, P, Col, Dec, MN" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "d_reel, 2, 0, P, Col, Dec, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "D, 2, 0, P, Col, Dec, MN" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "D, 2, 0, P, Col, Dec, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "error2, 2, 0, P, Col, Dec, MN" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "error2, 2, 0, P, Col, Dec, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "requete.data.val, 2, 0, P, Col, Dec, MN" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "gap, 2, 0, P, Col, Dec, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007" "d_reel, 2, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0007_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "requete.data.val, 2, 0, P, Col, Dec, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008" "capt_detecte, 2, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0008_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "9" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
@@ -325,14 +325,15 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_zemeta\tp_info6\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\programme_principal_etud.c" 
-"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_2018_zemeta\tp_info6\bsp\can.c" 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\dma0.c" 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\uart0.c" 
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_zemeta\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_zemeta\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_zemeta\tp_info6\Disassembly" 
+"E:\tp_info6_2018_zemeta\tp_info6\bsp\can.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -379,5 +380,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 102216336 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 92930608 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/zemeta/Emb_App/programme_principal_etud.c
===================================================================
--- branch/zemeta/Emb_App/programme_principal_etud.c	(revision 390)
+++ branch/zemeta/Emb_App/programme_principal_etud.c	(revision 391)
@@ -117,11 +117,9 @@
 //'I'/73/Ox49 : Définition du nom du véhicule. Doit débuter par le caractère '#' et entraine le chargement de la configuration de piste
 //				correspondant au nom du véhicule si le nom se termine par '*'
 CanFrame comm,comm2,comm3;
-unsigned short k=1,k2=1, angle_reel, error,error2,d_reel,D=714, d_max = 2000 ; // D = 500 pour piste verte , D = 714 pour piste verte
-unsigned short consigne_tour = 450 , vitesse = 10, capt_detecte ;  // V = 30 pour piste verte , V = 38 pour piste bleu  
-CanFrame requete,requete3,requete4 ; 
-char gap = 0;
-
+unsigned short k=1,k2=1, angle_reel, error,error2,d_reel,D/*=500*/, d_max = 2000 ; // D = 500 pour piste verte , D = 714 pour piste verte
+unsigned short consigne_tour/* = 900*/ , vitesse_roue/*=20*/, capt_detecte, comRoue;  ;  // V = 30 pour piste verte , V = 38 pour piste bleu  
+CanFrame requete,requete3,requete4 ;  
 
 void main()
 {
@@ -134,15 +132,16 @@
     clavier_init(1);
 	capture_init();
 	sta_tsk(ID_periph_rx);
-
-	//sta_cyc(ID_acqui);
-	
-	
+//	sta_tsk(id_trou);
+//	sta_cyc(ID_acqui);
+	sta_tsk(id_dist);
+
+	comRoue=-k2*error2 ;
+	sta_tsk(id_roue);
+	sta_tsk(id_detec);
 	sta_tsk(id_capt);
 	sta_tsk(id_angle);
 	sta_tsk(id_ass_t);	
-	sta_tsk(id_roue);
-	sta_tsk(id_dist);
 	dly_tsk(2000);
 	sta_tsk(id_avance);
 
@@ -165,7 +164,7 @@
 {
 	while (1)
 	{
-		requete.data.id = 'R' ; // variable requete sert a envoyter une requete.
+		requete.data.id = 'R' ; 
 		requete.data.rtr = 1 ;
 		snd_dtq(CanTx, requete.msg);
 		dly_tsk(5) ;
@@ -179,11 +178,11 @@
 
 void avance_voiture()
 {
-	while(1)
+	while(1) // Commande d'avance voiture
 	{
 		comm.data.id = 'V' ;
 		comm.data.rtr = 0 ;
-		comm.data.val = vitesse ; 
+		comm.data.val = vitesse_roue ; 
 		snd_dtq(CanTx, comm.msg) ;
 		dly_tsk(5);
 	}
@@ -193,9 +192,8 @@
 {
 	while(1)
 	{
-		//asservissement position tourelle
+		//asservissement position tourelle selon la consigne envoyée
 		error = consigne_tour - angle_reel ;
-		// envoie nouvelle commande tourelle 
 		comm.data.id = 'T' ;
 		comm.data.rtr = 0 ;
 		comm.data.val = k*error ; 
@@ -207,14 +205,14 @@
 
 void ass_roue()
 {
-	while(1)
+	while(1) // solution qui evite les trous a tous les coups
 	{
-		while (d_reel<d_max)
+		while (d_reel<=d_max)
 		{
 			error2 = D - d_reel ;
 			comm2.data.id = 'D' ;
 			comm2.data.rtr = 0 ;
-			comm2.data.val = -k2*error2 ; 
+			comm2.data.val = comRoue; 
 			snd_dtq(CanTx, comm2.msg) ;
 			dly_tsk(5) ; 
 		}
@@ -227,7 +225,7 @@
 {
 	while(1)
 	{
-		//recuperation distance telemetre
+		//Acquisition de la distance telemetre
 		requete3.data.id = 'U' ; 
 		requete3.data.rtr = 1 ;
 		snd_dtq(CanTx, requete3.msg);
@@ -240,11 +238,10 @@
 
 void trou()
 {
-	while(1)
+	while(1) // Solution pour eviter les roue mais marche pas tout le temps
 	{
-		while(d_reel>d_max)
+		while(d_reel>D)
 		{
-			error2 = D - d_reel ;
 			comm2.data.id = 'D' ;
 			comm2.data.rtr = 0 ;
 			comm2.data.val = 0 ; 
@@ -255,7 +252,7 @@
 	}
 }
 
-void capteur()
+void capteur() // detecteur de catpeurs des pistes
 {
 	while (1)
 	{
@@ -264,6 +261,30 @@
 		snd_dtq(CanTx, requete.msg);
 		dly_tsk(5) ;
 		capt_detecte = periph[ADDR('C')].val;
+		dly_tsk(10) ;
 	}
 }
 
+void detection() // Spéciale dédicace à la piste rouge 
+{
+	while (1)
+	{
+		LED_R=0;
+		if(capt_detecte!=22019) // course normale
+		{
+			D=710; 
+			consigne_tour=450;
+			vitesse_roue = 20;
+			comRoue = -k2*error2 ;
+		}
+		else if (capt_detecte==22019) // detection de ligne droite de saut
+		{
+			LED_R=1;
+			D=500; 
+			consigne_tour=900;
+			vitesse_roue = 45; // valeur pour un saut parfait  dr la piste rouge
+			comRoue = 0 ;
+		}
+		dly_tsk(10);
+	}
+}
Index: branch/zemeta/Emb_App/conf_noyau.cfg
===================================================================
--- branch/zemeta/Emb_App/conf_noyau.cfg	(revision 390)
+++ branch/zemeta/Emb_App/conf_noyau.cfg	(revision 391)
@@ -72,6 +72,7 @@
 	exinf	= 0x0;
 };
 
+
 task[]{
 	entry_address	= ass_roue();
 	name	= id_roue;
@@ -91,7 +92,18 @@
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
+
 task[]{
+	entry_address	= detection();
+	name	= id_detec;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 2;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= acquis_distance();
 	name	= id_dist;
 	stack_size	= 256;
Index: branch/zemeta/Emb_App/EmbM32C87App.tps
===================================================================
--- branch/zemeta/Emb_App/EmbM32C87App.tps	(revision 390)
+++ branch/zemeta/Emb_App/EmbM32C87App.tps	(revision 391)
@@ -18,7 +18,7 @@
 "SessionM32C_E8a_system" 
 [GENERAL_DATA_PROJECT]
 [GENERAL_DATA_CONFIGURATION_Debug]
-"PROJECT_FILES_MODIFIED_DATA_TAG" "FALSE" 
+"PROJECT_FILES_MODIFIED_DATA_TAG" "TRUE" 
 [SESSIONS_Debug]
 "DefaultSession" 
 "SessionM32C_E8a_system" 
