Index: branch/dupriet/Emb_App.tws
===================================================================
--- branch/dupriet/Emb_App.tws	(revision 281)
+++ branch/dupriet/Emb_App.tws	(revision 282)
@@ -9,15 +9,19 @@
 [OPEN_WORKSPACE_FILES]
 "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" 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\crt0mr.a30" 
+"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_dupriet\tp_info6\Emb_App\programme_principal_etud.c" 
 [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" 25 25 1430 351 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\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\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 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/dupriet/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/dupriet/Emb_App/SessionM32C_E8a_system.ini	(revision 281)
+++ branch/dupriet/Emb_App/SessionM32C_E8a_system.ini	(revision 282)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0024
+RESET=ff0020
Index: branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf	(revision 281)
+++ branch/dupriet/Emb_App/SessionM32C_E8a_system.hsf	(revision 282)
@@ -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" "0000000000FF3281" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF0576" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A34" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000838" 
-"{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_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_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" "0000000000000003" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000120000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A34" 
+"{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_7" "0000000000000512" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_8" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_9" "0000000000000000" 
@@ -209,7 +209,7 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "d, 2, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "lecturevit, 2, 0, P, Col, Dec, MA" 
+"{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}WatchWnd1ColWidth0" "120" 
@@ -313,11 +313,13 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"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\crt0mr.a30" 
+"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\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" 
-"E:\tp_info6_2018_dupriet\tp_info6\Emb_App\conf_noyau.cfg" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -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 96532928 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 102889376 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 281)
+++ branch/dupriet/Emb_App/programme_principal_etud.c	(revision 282)
@@ -124,21 +124,53 @@
 
 unsigned int consigne_angulaire =350;// 900;
 unsigned int alpha;
-unsigned int k = 3;
+unsigned int k = 3; //gain asserv tourelle
 unsigned int d;
 float roue=1;
-unsigned int celerite=40;
+int celerite=30;
 unsigned int norme= 870;//494;
 unsigned int lecturevit;
-float gain=1;
-unsigned int z;
+unsigned int capteur;
 
+
+void desactive(){
+	CanFrame req;
+	
+	UINT flag;
+	while(1){
+		req.data.id='C';
+		req.data.rtr=1;
+		periph[ADDR('C')].ev=0x01;
+		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);
+	}
+}
+
+
+
+
 void avancer(){
+	unsigned int z;
 	CanFrame comm;
 	CanFrame req;
 	UINT flag;
 	dly_tsk(1000);
-	while (1){/*		
+	
+	while (1){		
 		req.data.id='D';
 		req.data.rtr=1;
 		periph[ADDR('D')].ev=0x01;
@@ -146,18 +178,11 @@
 		wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
 		z=periph[ADDR('D')].val;
 		
-		if z<700{
-		comm.data.id='V';
-		comm.data.rtr=0;
-		comm.data.val=celerite;
-		snd_dtq(CanTx,comm.msg);}
-		else{
-		comm.data.id='V';
-		comm.data.rtr=0;
-		comm.data.val=celerite/2;
-		snd_dtq(CanTx,comm.msg);
-			}*/
-		dly_tsk(10);
+			comm.data.id='V';
+			comm.data.rtr=0;
+			comm.data.val=celerite;
+			snd_dtq(CanTx,comm.msg);
+		dly_tsk(1000);
 	}
 }
 
@@ -166,7 +191,7 @@
 	CanFrame req;
 	CanFrame com;
 	UINT flag;
-	dly_tsk(1000);
+	//dly_tsk(1000);
 	while (1){
 		req.data.id='U';
 		req.data.rtr=1;
@@ -174,23 +199,12 @@
 		snd_dtq(CanTx,req.msg);
 		wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
 		d=periph[ADDR('U')].val;
-		dly_tsk(4);
-		
-		
+		dly_tsk(4);		
 		if (d<1700){
 			comm.data.id='D';
 			comm.data.rtr=0;
 			comm.data.val=roue*(-norme+d);
 			snd_dtq(CanTx,comm.msg);}
-		
-		
-
-		
-		com.data.id='V';
-		com.data.rtr=0;
-		lecturevit=(celerite - gain*(abs(-norme+d)/norme));
-		com.data.val=lecturevit;
-		snd_dtq(CanTx,com.msg);
 		dly_tsk(10);
 	}
 }
@@ -214,7 +228,7 @@
 			comm.data.rtr=0;
 			comm.data.val=k * (consigne_angulaire - alpha);
 			snd_dtq (CanTx,comm.msg);
-			dly_tsk(2);
+			dly_tsk(10);
 		}	
 }
 
@@ -230,13 +244,14 @@
     clavier_init(1);
 	capture_init();
 	//sta_tsk(ID_avancer);
-	sta_cyc(ID_acqui);
+	//sta_cyc(ID_acqui);
 	sta_tsk(ID_asserv_tourelle);
 	sta_tsk(ID_asserv_direction);
 	sta_tsk(ID_periph_rx);
-
+	sta_tsk(ID_desactive);
     while(1)
     {
+		dly_tsk(100);
 		/*
 		LED_J=1;
 		dly_tsk(100);
Index: branch/dupriet/Emb_App/conf_noyau.cfg
===================================================================
--- branch/dupriet/Emb_App/conf_noyau.cfg	(revision 281)
+++ branch/dupriet/Emb_App/conf_noyau.cfg	(revision 282)
@@ -92,6 +92,16 @@
 	exinf	= 0x0;
 };
 
+task[]{
+	entry_address	= desactive();
+	name	= ID_desactive;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 6;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
Index: branch/dupriet/Emb_App/EmbM32C87App.tps
===================================================================
--- branch/dupriet/Emb_App/EmbM32C87App.tps	(revision 281)
+++ branch/dupriet/Emb_App/EmbM32C87App.tps	(revision 282)
@@ -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" 
