Index: branch/dupriet/Emb_App.tws
===================================================================
--- branch/dupriet/Emb_App.tws	(revision 333)
+++ branch/dupriet/Emb_App.tws	(revision 334)
@@ -7,6 +7,7 @@
 [GENERAL_DATA]
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
+"E:\tp_info6_2018_dupriet\tp_info6\bsp\lcd.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.h" 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\uart0.c" 
@@ -17,8 +18,9 @@
 [WORKSPACE_FILE_STATES]
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\Debug\mr308.inc" 150 150 1405 394 0 6 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\conf_noyau.cfg" 75 75 1430 351 0 2 
-"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\crt0mr.a30" -8 -30 1596 607 1 1 
-"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\programme_principal_etud.c" 0 0 1596 607 0 0 
+"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\crt0mr.a30" 0 0 1596 607 0 1 
+"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 607 1 0 
+"E:\tp_info6_2018_dupriet\tp_info6\bsp\lcd.c" 175 175 1405 394 0 7 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.c" 100 100 1405 394 0 4 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.h" 75 75 1405 394 0 3 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\uart0.c" 125 125 1405 394 0 5 
Index: branch/dupriet/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/dupriet/Emb_App/SessionM32C_E8a_system.ini	(revision 333)
+++ branch/dupriet/Emb_App/SessionM32C_E8a_system.ini	(revision 334)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0020
+RESET=ff0024
Index: branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf	(revision 333)
+++ branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf	(revision 334)
@@ -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" "0000000000004044" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000020" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_0" "000000000000FFD7" 
+"{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" 
@@ -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" "0000000000FF0576" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF3598" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000B0E" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000848" 
-"{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_18" "0000000000000A60" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000864" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C0" 
 "{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" "0000000000000008" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000B44" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000000006" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000120000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A60" 
 "{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" 
@@ -211,7 +211,13 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "capteur, 2, 0, P, Col, Hex, 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" "compteur_tours, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "celerite, 1, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Global," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "piste, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "6" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -313,12 +319,13 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\crt0mr.a30" 
-"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\uart0.c" 
-"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_dupriet\tp_info6\bsp\lcd.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\Debug\mr308.inc" 
-"E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.c" 
 "E:\tp_info6_2018_dupriet\tp_info6\bsp\periph.h" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
@@ -366,5 +373,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 102889376 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 86112296 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/dupriet/Emb_App/programme_principal_etud.c
===================================================================
--- branch/dupriet/Emb_App/programme_principal_etud.c	(revision 333)
+++ branch/dupriet/Emb_App/programme_principal_etud.c	(revision 334)
@@ -127,15 +127,18 @@
 unsigned int k = 3; //gain asserv tourelle
 unsigned int d;
 float roue=1;
-int celerite=30;
+int celerite=50;
 unsigned int norme= 870;//494;
 unsigned int lecturevit;
 unsigned int capteur;
+unsigned int compteur_tours=0;
+char c[]="";
+unsigned int piste;
+unsigned short STOP=0;
 
-
-void desactive(){
+void capteur_couleur(){
 	CanFrame req;
-	
+	unsigned int detect_change=0;
 	UINT flag;
 	while(1){
 		req.data.id='C';
@@ -144,20 +147,60 @@
 		snd_dtq(CanTx,req.msg);
 		wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
 		capteur=periph[ADDR('C')].val;
-		
-		if(capteur==0x5601){celerite=50;}
-		if(capteur==0x4a01){celerite=5;}
-		if(capteur==0x5602){celerite=50;}
-		if(capteur==0x5202){celerite=5;}
-		if(capteur==0x5603){celerite=50;}
-		if(capteur==0x4203){celerite=5;}
-		if(capteur==0x5604){celerite=50;}
-		if(capteur==0x4304){celerite=5;}
-		
-		if (capteur==0x7610){celerite=50;roue=0;}
-		if (capteur==0x7611){celerite=0;dly_tsk(1500);roue=1;celerite=10;dly_tsk(800);celerite=30;}
-		dly_tsk(5);
-	}
+		if(compteur_tours!=0x7610
+			&& compteur_tours!=0x7611
+			&& compteur_tours!=0x7612
+			&&detect_change!=capteur)		//protocole pour compter le nombre de tours
+				{detect_change=capteur;
+			if(compteur_tours<27){
+				compteur_tours++;}
+			else{STOP++;}
+			}
+	
+		switch(capteur) {
+			case 0x5601:		//début détection lasers aux angles de la piste
+				celerite=50;
+				break;
+			case 0x4a01:
+				celerite=25;
+				break;
+			case 0x5602:
+				celerite=50;
+				break;
+			case 0x5202:
+				celerite=25;
+				break;
+			case 0x5603:
+				celerite=50;
+				break;
+			case 0x4203:
+				celerite=25;
+				break;
+			case 0x5604:
+				celerite=50;
+				break;
+			case 0x4304:
+				celerite=20;
+				break;			//fin détection lasers aux angles de la piste
+				
+			case 0x7612:		//piste bleue	//vert 18 petit
+				celerite=20;
+				break;
+			
+			case 0x7610:		//début saut piste rouge	//vert petit 16
+				celerite=55;
+				roue=0;
+				break;
+			case 0x7611:	//vert petit 17
+				celerite=0;
+				dly_tsk(1500);
+				roue=1;
+				celerite=10;
+				dly_tsk(800);
+				celerite=20;
+				break;			//fin saut piste rouge
+		}
+	dly_tsk(5);}
 }
 
 
@@ -178,11 +221,11 @@
 		wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
 		z=periph[ADDR('D')].val;
 		
-			comm.data.id='V';
-			comm.data.rtr=0;
-			comm.data.val=celerite;
-			snd_dtq(CanTx,comm.msg);
-		dly_tsk(1000);
+		comm.data.id='V';
+		comm.data.rtr=0;
+		comm.data.val=celerite;
+		snd_dtq(CanTx,comm.msg);
+		dly_tsk(100);		//libere le processeur
 	}
 }
 
@@ -200,7 +243,7 @@
 		wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
 		d=periph[ADDR('U')].val;
 		dly_tsk(4);		
-		if (d<1700){
+		if (d<2000){
 			comm.data.id='D';
 			comm.data.rtr=0;
 			comm.data.val=roue*(-norme+d);
@@ -231,6 +274,22 @@
 			dly_tsk(10);
 		}	
 }
+
+void afficheur(){/*
+		CanFrame req;
+		UINT flag;
+		while(1){
+			req.data.id='H';
+			req.data.rtr=1;
+			periph[ADDR('H')].ev=0x01;
+			snd_dtq(CanTx,req.msg);
+			wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
+			piste = periph[ADDR('H')].val;
+			dly_tsk(100);
+			c=('%d',piste);
+			lcd_str(c);
+		}*/
+}
 
 void main()
 {
@@ -238,21 +297,29 @@
 	ports_mcu();
     lcd_init();
 	periph_init();
-	periph_nom("#Anaec*");
-
+	periph_nom("#Anaec*");
+	lcd_str(c);
     can_init();
     clavier_init(1);
 	capture_init();
-	//sta_tsk(ID_avancer);
+	sta_tsk(ID_avancer);
 	//sta_cyc(ID_acqui);
+	//sta_tsk(ID_afficheur);
 	sta_tsk(ID_asserv_tourelle);
 	sta_tsk(ID_asserv_direction);
 	sta_tsk(ID_periph_rx);
-	sta_tsk(ID_desactive);
+	sta_tsk(ID_capteur_couleur);
     while(1)
     {
+		if(STOP){
+			ter_tsk(ID_asserv_tourelle);
+			ter_tsk(ID_asserv_direction);
+			ter_tsk(ID_periph_rx);
+			ter_tsk(ID_capteur_couleur);
+			ter_tsk(ID_avancer);
+			}
+		/*
 		dly_tsk(100);
-		/*
 		LED_J=1;
 		dly_tsk(100);
 		LED_J=0;
@@ -264,6 +331,6 @@
 
 void acqui()
 {
-	//LED_V=!LED_V;
+	LED_V=!LED_V;
 }
 
Index: branch/dupriet/Emb_App/conf_noyau.cfg
===================================================================
--- branch/dupriet/Emb_App/conf_noyau.cfg	(revision 333)
+++ branch/dupriet/Emb_App/conf_noyau.cfg	(revision 334)
@@ -77,7 +77,7 @@
 	name	= ID_avancer;
 	stack_size	= 256;
 	stack_section	= stack;
-	priority	= 3;
+	priority	= 2;
 	initial_start	= OFF;
 	exinf	= 0x0;
 };
@@ -93,10 +93,20 @@
 };
 
 task[]{
-	entry_address	= desactive();
-	name	= ID_desactive;
+	entry_address	= capteur_couleur();
+	name	= ID_capteur_couleur;
 	stack_size	= 256;
 	stack_section	= stack;
+	priority	= 1;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
+	entry_address	= afficheur();
+	name	= ID_afficheur;
+	stack_size	= 256;
+	stack_section	= stack;
 	priority	= 6;
 	initial_start	= OFF;
 	exinf	= 0x0;
