Index: branch/mbaye/Emb_App.tws
===================================================================
--- branch/mbaye/Emb_App.tws	(revision 268)
+++ branch/mbaye/Emb_App.tws	(revision 269)
@@ -7,9 +7,19 @@
 [GENERAL_DATA]
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\clavier.c" 
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\crt0mr.a30" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_2018_mbaye\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
-"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\programme_principal_etud.c" 0 0 1426 497 0 0 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\Debug\mr308.inc" 0 0 1430 351 0 5 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\conf_noyau.cfg" 0 474 160 38 0 1 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\crt0mr.a30" 0 0 1596 539 0 3 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 4 
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\clavier.c" 480 474 160 38 0 0 
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\periph.c" 320 474 160 38 0 2 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/mbaye/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/mbaye/Emb_App/SessionM32C_E8a_system.hsf	(revision 268)
+++ branch/mbaye/Emb_App/SessionM32C_E8a_system.hsf	(revision 269)
@@ -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" "0000000000FF0580" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000BBA" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000007EA" 
-"{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" "0000000000000008" 
+"{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" "0000000000000BE6" 
-"{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" 
@@ -205,13 +205,13 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth2" "120" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth3" "200" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "d, 2, 0, P, Col, Hex, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "dis, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "com, 2, 0, P, Col, Hex, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "pos, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "b, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "pos_tourelle, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "a, 2, 0, P, Col, Hex, MN" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "a, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "4" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
@@ -274,7 +274,7 @@
 [LANGUAGE]
 "English" 
 [CONFIG_INFO_VD1]
-0 
+1 
 [CONFIG_INFO_VD2]
 0 
 [CONFIG_INFO_VD3]
@@ -283,7 +283,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.09" 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" 
@@ -316,6 +316,11 @@
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
 "E:\tp_info6_2018_mbaye\tp_info6\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\crt0mr.a30" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\Debug\mr308.inc" 
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_mbaye\tp_info6\bsp\clavier.c" 
+"E:\tp_info6_2018_mbaye\tp_info6\Emb_App\conf_noyau.cfg" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -362,5 +367,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 120622032 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 89980032 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/mbaye/Emb_App/programme_principal_etud.c
===================================================================
--- branch/mbaye/Emb_App/programme_principal_etud.c	(revision 268)
+++ branch/mbaye/Emb_App/programme_principal_etud.c	(revision 269)
@@ -27,14 +27,15 @@
 #include "carte_m32.h"
 #include <math.h>
 
-unsigned int com; //commande
-int pos_tourelle;
-int vitesse;
+//unsigned int com; //commande
+//int pos_tourelle;
+//int vitesse;
 int pos;
 int dis;
-int a;
+UINT flag;
+//int a;
 //int b;
-UINT flag;
+
   
 // Potentiometre: lire les registres ad00 et ad01, les valeurs sont sur 10 bits.
 
@@ -130,7 +131,52 @@
 //				correspondant au nom du véhicule si le nom se termine par '*'
 
 
-
+void asserv_T()
+{
+	while(1)
+	{
+	   CanFrame comm,req; 
+	   req.data.id='R'; req.data.rtr=1;
+       periph[ADDR('R')].ev= 0x01;
+	   snd_dtq (CanTx,req.msg);
+	   wai_flg(ev_periph, 0x01, TWF_ANDW, &flag);
+       pos = periph[ADDR('R')].val;
+	  // dly_tsk(100);
+	
+	   comm.data.id='T'; comm.data.rtr=0; 
+	   comm.data.val=450-pos;
+	   snd_dtq (CanTx,comm.msg);
+	   dly_tsk(100);
+	}
+	
+}
+void dist_T()
+{
+	while(1)
+	{
+	   CanFrame comm,req;
+	   req.data.id='U'; req.data.rtr=1;
+	   periph[ADDR('U')].ev= 0x01;
+	   snd_dtq (CanTx,req.msg);
+	   wai_flg(ev_periph, 0x01, TWF_ANDW, &flag);
+       dis = periph[ADDR('U')].val;
+	   //dly_tsk(100);
+	
+	   comm.data.id='D'; comm.data.rtr=0; 
+	   comm.data.val=-(450-dis);
+	   snd_dtq (CanTx,comm.msg);
+	   dly_tsk(100);
+	}
+}
+void vitesse_roue()
+{
+	   CanFrame comm;
+	   dly_tsk(3000);
+	   comm.data.id='V'; comm.data.rtr=0; 
+	   comm.data.val=15;
+	   snd_dtq (CanTx,comm.msg);
+	   dly_tsk(100);
+}
 void main()
 {
 	ports_mcu();
@@ -144,66 +190,15 @@
 
 	sta_cyc(ID_acqui);
 	sta_tsk(ID_periph_rx);
+	
+	sta_tsk(ID_asserv_T);
+	sta_tsk(ID_dist_T);
+	sta_tsk(ID_vitesse_roue);
 	
 
     while(1)
     {
-	    CanFrame m; CanFrame req;
-
-        m.data.id='T'; m.data.rtr=0; m.data.val=45;
-		pos_tourelle=m.data.val;
-	    snd_dtq (CanTx,m.msg);
-		dly_tsk(100);
-		
-		m.data.id='R'; m.data.rtr=1;
-	    snd_dtq (CanTx,m.msg);
-		a= periph[ADDR('R')].val;
-		dly_tsk(100);
-		
-		if(a>90)
-		{
-			m.data.id='T'; m.data.rtr=0;
-			pos_tourelle=0;
-			snd_dtq (CanTx,m.msg);
-		    dly_tsk(100);
-		}
-	
-		m.data.id='V'; m.data.rtr=0; m.data.val=35;
-	    snd_dtq (CanTx,m.msg);
-		dly_tsk(100);
-		//rcv_dtq(CanRx, &m.msg);
-		switch(m.data.id)
-		{
-			case 'T':
-			 // pos_tourelle=m.data.val;
-			  req.data.id='R';
-			  req.data.rtr=1;
-	          periph[ADDR('R')].ev=0x01;
-			  snd_dtq(CanTx, req.msg);
-			  wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
-	          pos=periph[ADDR('R')].val;
-			  
-			  //pos_tourelle=1.2*(45-pos); snd_dtq (CanTx,m.msg);
-			  dly_tsk(100);
-			  break;
-			  
-			case 'V':
-			  vitesse=m.data.val;
-			  req.data.id='U';
-			  req.data.rtr=1;
-			  periph[ADDR('U')].ev=0x01;
-			  snd_dtq(CanTx, req.msg);
-			  wai_flg(ev_periph,0x01,TWF_ANDW,&flag);
-			  dis=periph[ADDR('U')].maj;  
-			  dly_tsk(150);
-			  break;
-		}
-		if (dis>14)
-	         	{
-			       m.data.id='D'; m.data.rtr=0; m.data.val=-4,5;
-	               snd_dtq (CanTx,m.msg); dly_tsk(150);
-			
-	          	}
+	   dly_tsk(1000); 
     }
 		
 }
Index: branch/mbaye/Emb_App/conf_noyau.cfg
===================================================================
--- branch/mbaye/Emb_App/conf_noyau.cfg	(revision 268)
+++ branch/mbaye/Emb_App/conf_noyau.cfg	(revision 269)
@@ -9,7 +9,7 @@
 // system definition
 system{
 	stack_size	= 256;
-	priority	= 8;
+	priority	= 11;
 	system_IPL	 = 4;
 	message_pri	 = 1;
 	timeout	 = YES;
@@ -20,7 +20,7 @@
 
 // max definition
 maxdefine{
-	max_task	= 3;
+	max_task	= 6;
 	max_flag	= 3;
 	max_dtq	= 2;
 	max_cyh	= 1;
@@ -44,6 +44,33 @@
 	exinf	= 0x0;
 };
 task[]{
+	entry_address	= asserv_T();
+	name	= ID_asserv_T;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 9;
+	initial_start	= ON;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= dist_T();
+	name	= ID_dist_T;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 9;
+	initial_start	= ON;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= vitesse_roue();
+	name	= ID_vitesse_roue;
+	stack_size	= 512;
+	stack_section	= stack;
+	priority	= 9;
+	initial_start	= ON;
+	exinf	= 0x0;
+};
+task[]{
 	entry_address	= periph_tx();
 	name	= ID_periph_tx;
 	stack_size	= 256;
@@ -58,7 +85,7 @@
 	stack_size	= 256;
 	stack_section	= stack;
 	priority	= 2;
-	initial_start	= OFF;
+	initial_start	= ON;
 	exinf	= 0x0;
 };
 flag[]{
Index: branch/mbaye/Emb_App/EmbM32C87App.tps
===================================================================
--- branch/mbaye/Emb_App/EmbM32C87App.tps	(revision 268)
+++ branch/mbaye/Emb_App/EmbM32C87App.tps	(revision 269)
@@ -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" 
