Index: branch/elmansour/Emb_App.tws
===================================================================
--- branch/elmansour/Emb_App.tws	(revision 381)
+++ branch/elmansour/Emb_App.tws	(revision 382)
@@ -7,6 +7,8 @@
 [GENERAL_DATA]
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
+"E:\tp_info6_elmansour\bsp\carte_m32.h" 
+"E:\tp_info6_elmansour\bsp\lcd.c" 
 "E:\tp_info6_elmansour\bsp\periph.c" 
 "E:\tp_info6_elmansour\bsp\radiocommande.c" 
 "E:\tp_info6_elmansour\bsp\uart0.c" 
@@ -19,8 +21,10 @@
 "E:\tp_info6_elmansour\Emb_App\Debug\mr308.inc" 0 0 1430 351 0 7 
 "E:\tp_info6_elmansour\Emb_App\Debug\mrtable.a30" 50 50 1430 351 0 1 
 "E:\tp_info6_elmansour\Emb_App\conf_noyau.cfg" 75 75 1430 351 0 2 
-"E:\tp_info6_elmansour\Emb_App\crt0mr.a30" -8 -30 1596 539 1 6 
-"E:\tp_info6_elmansour\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 0 
+"E:\tp_info6_elmansour\Emb_App\crt0mr.a30" 0 0 1596 539 0 6 
+"E:\tp_info6_elmansour\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 0 
+"E:\tp_info6_elmansour\bsp\carte_m32.h" 50 50 1430 351 0 9 
+"E:\tp_info6_elmansour\bsp\lcd.c" 25 25 1430 351 0 8 
 "E:\tp_info6_elmansour\bsp\periph.c" 100 100 1430 351 0 3 
 "E:\tp_info6_elmansour\bsp\radiocommande.c" 125 125 1430 351 0 4 
 "E:\tp_info6_elmansour\bsp\uart0.c" 0 0 1430 351 0 5 
Index: branch/elmansour/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/elmansour/Emb_App/SessionM32C_E8a_system.ini	(revision 381)
+++ branch/elmansour/Emb_App/SessionM32C_E8a_system.ini	(revision 382)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff001a
+RESET=ff001c
Index: branch/elmansour/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/elmansour/Emb_App/SessionM32C_E8a_system.hsf	(revision 381)
+++ branch/elmansour/Emb_App/SessionM32C_E8a_system.hsf	(revision 382)
@@ -141,7 +141,7 @@
 "{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" "0000000000000000" 
+"{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_10" "0000000000000000" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_11" "0000000000000000" 
@@ -148,13 +148,13 @@
 "{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" "0000000000000000" 
-"{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" "000000000000C400" 
-"{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_15" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF339C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000A6C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000870" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "00000000000000F0" 
+"{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" 
@@ -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" "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" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{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_4" "0000000000000009" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "00000000000CE4F6" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000A6C" 
+"{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" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_COUNT" "36" 
@@ -207,9 +207,11 @@
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH" "c,buff,n,rx,flag," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "dishorizontale, 10, 0, P, Col, Dec, N" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "capteur, 10, 0, P, Col, Dec, N" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "2" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "distance, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Global," 
+"{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" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "200" 
@@ -279,14 +281,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 2 "0.12" 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 2 "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 -4 -30 948 486 9 0 "" "0.0" 
-"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.05" 365 0 0 350 200 18 0 "32774|32775|32777|<<separator>>|32780|<<separator>>" "0.0" 
+"{WK_00000001_EVENT}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 1 "0.01" 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 0 "0.76" 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 4 "0.05" 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_OUTPUT}" "WINDOW" 59422 0 0 "0.78" 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 4 "0.03" 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" 59422 0 3 "0.14" 365 0 0 350 200 18 0 "32781|32783|<<separator>>|32771|32772|32773|<<separator>>|32786|<<separator>>|32810|32811" "0.0" 
+"{WK_00000001_WATCH}EmbM32C87AppSessionM32C_E8a_system" "WINDOW" 59422 0 3 "0.18" 365 0 0 350 200 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" 
@@ -311,14 +313,16 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_elmansour\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_elmansour\Emb_App\crt0mr.a30" 
-"E:\tp_info6_elmansour\Emb_App\programme_principal_etud.c" 
 "E:\tp_info6_elmansour\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_elmansour\bsp\uart0.c" 
+"E:\tp_info6_elmansour\bsp\lcd.c" 
+"E:\tp_info6_elmansour\bsp\carte_m32.h" 
 "E:\tp_info6_elmansour\bsp\radiocommande.c" 
 "E:\tp_info6_elmansour\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_elmansour\Emb_App\Debug\mrtable.a30" 
 "E:\tp_info6_elmansour\bsp\periph.c" 
-"E:\tp_info6_elmansour\bsp\uart0.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
Index: branch/elmansour/Emb_App/programme_principal_etud.c
===================================================================
--- branch/elmansour/Emb_App/programme_principal_etud.c	(revision 381)
+++ branch/elmansour/Emb_App/programme_principal_etud.c	(revision 382)
@@ -120,7 +120,7 @@
 //'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 '*'
 unsigned alpha;
-int k=1;
+int k=3;
 unsigned agl_roue;
 unsigned distance;
 unsigned dishorizontalfix;
@@ -127,6 +127,8 @@
 unsigned dishorizontal;
 unsigned erreur=0;
 unsigned vits;
+unsigned short capteur;
+int s=1;
 
 
 void tourelle(){
@@ -152,12 +154,19 @@
 		comm.data.rtr=0;
 		comm.data.val=k*(450-alpha);
 		snd_dtq(CanTx,comm.msg);
-		dly_tsk(20);
+		dly_tsk(100);
 	}
 }
 
 void demarrer (){
-	dly_tsk(5000);
+	dly_tsk(3000);
+	/*CanFrame requete;
+	requete.data.id='V';
+	requete.data.rtr=0;
+	requete.data.val=30;
+	snd_dtq(CanTx, requete.msg);
+	dly_tsk(1000);*/
+	
 	while(1){
 	CanFrame requete;
 	/*do{
@@ -165,8 +174,12 @@
 	}while(abs(k*(450-alpha))>2); */
 	requete.data.id='V';
 	requete.data.rtr=0;
-	vits=45;
-	if(abs(distance-707)>30) requete.data.val=30;
+	if(capteur==0x5601 ) {requete.data.val=75;s=1;k=1;}
+	else if (capteur==0x5602 || capteur==0x5203 || capteur==0x5604 || capteur==0x5605 ){requete.data.val=65;s=1;k=3;}
+	else if(capteur==0x6a01 ) {requete.data.val=55;s=1;k=3;}
+	else if(capteur==0x4a01 || capteur==0x5202 || capteur==0x4203 || capteur==0x4304 /*|| 30<abs(distance-707)*/) {requete.data.val=30;s=3;k=4;}
+	else if (capteur==0x7602 || capteur==0x7601){requete.data.val=10;s=0;k=1;}
+
 	/*{
 	do{
 	if(vits>20) vits=vits-7;
@@ -174,7 +187,7 @@
 	dly_tsk(5);
 	}while(abs(distance-707)>10);
 	}*/
-	else requete.data.val=vits;
+	else {requete.data.val=70;s=1;k=1;}
 	snd_dtq(CanTx, requete.msg);
 	dly_tsk(5);
 	}
@@ -181,7 +194,6 @@
 }
 
 void roues(){
-	dly_tsk(1000);
 	/*req.data.id='D';
 	req.data.rtr=1;
 	periph[ADDR('D')].ev=0x02;
@@ -197,9 +209,10 @@
 	//erreur=dishorizontal-dishorizontalfix;
 	comm.data.id='D';
 	comm.data.rtr=0;
-	comm.data.val=2*(distance-707);
+	//if(capteur==0x6701){ comm.data.val=0;}
+    comm.data.val=s*(distance-706);
 	snd_dtq(CanTx, comm.msg);
-	dly_tsk(10);
+	dly_tsk(20);
 	}
 		
 }
@@ -220,16 +233,18 @@
 }
 void capt(){
 	while(1){
-	CanFrame req;
-	int capteur;
-	UINT flag;
-	req.data.id='C';
-	req.data.rtr=1;
-	periph[ADDR('R')].ev=0x03;
-	snd_dtq(CanTx, req.msg);
-	wai_flg(ev_periph, 0x03, TWF_ANDW, &flag);
-	capteur=periph[ADDR('C')].val;
-	dly_tsk(20);
+        CanFrame requete;
+        UINT flag;
+        
+        requete.data.id = 'C';
+        requete.data.rtr = 1;          // Requete de lecture 
+        periph[ADDR('C')].ev =0x03;
+        snd_dtq(CanTx, requete.msg);
+        
+        wai_flg(ev_periph, 0x03, TWF_ANDW, &flag);
+        
+        capteur=periph[ADDR('C')].val;
+	    dly_tsk(20);
 	}
 	}
 void feurouge(){
@@ -248,15 +263,12 @@
 	}
 
 
-void main()
-
-{
-	CanFrame comm;
+void main(){
+/*	CanFrame comm;
 		comm.data.id='T';
 		comm.data.rtr=0;
 		comm.data.val=120;
-		snd_dtq(CanTx,comm.msg);
-		dly_tsk(20);	
+		snd_dtq(CanTx,comm.msg);*/
 	ports_mcu();
     lcd_init();
 	periph_init();
@@ -277,14 +289,12 @@
 		sta_tsk(ID_capt);
 		sta_tsk(ID_feurouge);
 	
-    while(1)
-    {
+    while(1){
 		/*LED_J=1;
 		dly_tsk(100);
 		LED_J=0;
 		dly_tsk(100);
 		//tourelle();*/
-
     }
 }
 
Index: branch/elmansour/Emb_App/DefaultSession.hsf
===================================================================
--- branch/elmansour/Emb_App/DefaultSession.hsf	(revision 381)
+++ branch/elmansour/Emb_App/DefaultSession.hsf	(revision 382)
@@ -59,13 +59,15 @@
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
 "E:\tp_info6_elmansour\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_elmansour\Emb_App\crt0mr.a30" 
+"E:\tp_info6_elmansour\bsp\uart0.c" 
 "E:\tp_info6_elmansour\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_elmansour\Emb_App\crt0mr.a30" 
+"E:\tp_info6_elmansour\bsp\lcd.c" 
+"E:\tp_info6_elmansour\bsp\carte_m32.h" 
 "E:\tp_info6_elmansour\bsp\radiocommande.c" 
 "E:\tp_info6_elmansour\Emb_App\Debug\mr308.inc" 
 "E:\tp_info6_elmansour\Emb_App\Debug\mrtable.a30" 
 "E:\tp_info6_elmansour\bsp\periph.c" 
-"E:\tp_info6_elmansour\bsp\uart0.c" 
 [TARGET_NAME]
 "" "" 0 
 [STATUSBAR_STATEINFO_VD1]
