Index: branch/zhang/Emb_App.tws
===================================================================
--- branch/zhang/Emb_App.tws	(revision 204)
+++ branch/zhang/Emb_App.tws	(revision 205)
@@ -7,21 +7,19 @@
 [GENERAL_DATA]
 [BREAKPOINTS]
 [OPEN_WORKSPACE_FILES]
-"E:\tp_info6_zhan\bsp\periph.c" 
-"E:\tp_info6_zhan\bsp\periph.h" 
+"C:\Program Files (x86)\Renesas\Hew\Tools\Renesas\nc308wa\v542r00\inc308\stdlib.h" 
+"E:\tp_info6_zhan\bsp\lcd.c" 
 "E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_zhan\Emb_App\crt0mr.a30" 
 "E:\tp_info6_zhan\Emb_App\Debug\kernel_id.h" 
-"E:\tp_info6_zhan\Emb_App\Debug\mrtable.a30" 
 "E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
-"E:\tp_info6_zhan\Emb_App\Debug\kernel_id.h" 75 75 1430 351 0 6 
-"E:\tp_info6_zhan\Emb_App\Debug\mrtable.a30" 50 50 1430 351 0 5 
-"E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 50 50 1430 351 0 2 
-"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 0 0 1426 347 0 0 
-"E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" -8 -30 1596 539 1 1 
-"E:\tp_info6_zhan\bsp\periph.c" 25 25 1430 351 0 4 
-"E:\tp_info6_zhan\bsp\periph.h" 75 75 1430 351 0 3 
+"C:\Program Files (x86)\Renesas\Hew\Tools\Renesas\nc308wa\v542r00\inc308\stdlib.h" 150 150 1430 351 0 6 
+"E:\tp_info6_zhan\Emb_App\Debug\kernel_id.h" 75 75 1430 351 0 5 
+"E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 25 25 1430 351 0 4 
+"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 125 125 1426 347 0 1 
+"E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" 0 0 1596 539 0 2 
+"E:\tp_info6_zhan\bsp\lcd.c" -8 -30 1596 539 1 3 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/zhang/Emb_App/SessionM32C_E8a_system.ini
===================================================================
--- branch/zhang/Emb_App/SessionM32C_E8a_system.ini	(revision 204)
+++ branch/zhang/Emb_App/SessionM32C_E8a_system.ini	(revision 205)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=ff0012
+RESET=ff0122
Index: branch/zhang/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/zhang/Emb_App/SessionM32C_E8a_system.hsf	(revision 204)
+++ branch/zhang/Emb_App/SessionM32C_E8a_system.hsf	(revision 205)
@@ -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" "0000000000000258" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000000001" 
 "{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" "0000000000FF056A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF2FBF" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000009DC" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000007FE" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000001466" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000BCE" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000004004" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C8" 
 "{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_4" "00000000000014A4" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000009FA" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "000000000000146C" 
 "{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" 
@@ -277,8 +277,8 @@
 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_DISASSEMBLY}" "WINDOW" 0 0 0 "0.00" 0 -4 -30 948 486 9 0 "" "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 50 50 1430 351 10 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" 
 "{WK_00000001_OUTPUT}" "WINDOW" 59422 0 2 "0.52" 365 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
@@ -309,13 +309,13 @@
 [WINDOW_POSITION_STATE_DATA_VD3]
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
+"E:\tp_info6_zhan\bsp\lcd.c" 
+"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 
+"C:\Program Files (x86)\Renesas\Hew\Tools\Renesas\nc308wa\v542r00\inc308\stdlib.h" 
 "E:\tp_info6_zhan\Emb_App\programme_principal_etud.c" 
-"E:\tp_info6_zhan\Emb_App\crt0mr.a30" 
 "E:\tp_info6_zhan\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_zhan\bsp\periph.h" 
 "E:\tp_info6_zhan\Emb_App\Debug\kernel_id.h" 
-"E:\tp_info6_zhan\Emb_App\Debug\mrtable.a30" 
-"E:\tp_info6_zhan\bsp\periph.c" 
+"E:\tp_info6_zhan\Disassembly" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
 [STATUSBAR_STATEINFO_VD1]
@@ -362,5 +362,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 91688328 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 91677544 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/zhang/Emb_App/programme_principal_etud.c
===================================================================
--- branch/zhang/Emb_App/programme_principal_etud.c	(revision 204)
+++ branch/zhang/Emb_App/programme_principal_etud.c	(revision 205)
@@ -71,7 +71,7 @@
 
 // Pour qu'un evenement soit declenche lors de la reception d'une donnee pour un peripherique:
 // periph[ADDR('R')].ev=0x01;
-// Pour se mettre en attente de l'evenement: wai_flg (ev_periph,0x01,TWF_ORW,&flag); // Declarer la variable flag comme : FLGPTN flag
+// Pour se mettre en attente de l'evenement:  (ev_periph,0x01,TWF_ORW,&flag); // Declarer la variable flag comme : FLGPTN flag
 // Attention l'evenement n'est pas efface apres reception, il faut donc utiliser clr_flg(ev_periph,~0x01); par example
 
 // Les evenements:
@@ -120,7 +120,8 @@
 //'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 '*'
 
-int alpha; //angle
+unsigned int alpha; //angle
+unsigned int distance; // Distance mesuree par le telemetre (1/100 de metre)
 
 void main()
 {
@@ -134,15 +135,20 @@
 	capture_init();
 
 	sta_cyc(ID_acqui);
-//	sta_tsk(ID_periph_rx);
-	sta_cyc(ID_asserv);
-//	sta_tsk(ID_control_tourelle);
+	sta_tsk(ID_periph_rx);     //config de periph, donc je peut utilise periph(R U)
+/******************************************************************************************/	
+	
+//	sta_cyc(ID_asserv);
+	sta_tsk(ID_control_tourelle);
+	sta_tsk(ID_control_direct);
 //	sta_tsk(ID_angle_T);                       
 //	sta_tsk(ID_vitesse_T);
-//	dly_tsk(2000);
+//	dly_tsk(2000);	
+	sta_tsk(ID_vitesse);
+	sta_cyc(ID_affiche);
 
 	
-	
+/*********************************************************************************************/	
 	
     while(1)
     {
@@ -151,17 +157,16 @@
 		LED_J=0;
 		dly_tsk(100);
 		
-//		sta_tsk(ID_acqui);
-//		dly_tsk(100);
+
     }
 }
-
+/*
 void asserv()
 {
 	iwup_tsk(ID_control_tourelle);	
 }
+*/
 
-
 void acqui()
 {
 	LED_V=!LED_V;
@@ -173,24 +178,26 @@
 	// et commande la vitesse de tourelle(asservissement)
 	CanFrame requete, reponse, comm; 
 	FLGPTN flag;
-	int a,c;
+	int a;
 	while(1){	
-	slp_tsk();
+//	slp_tsk();
 	requete.data.id = 'R';			// angle de tourelle
 	requete.data.rtr = 1;			//indique une requête(demende) de lecture
+	periph[ADDR('R')].ev=0x01;		// event mise au 0x01
 	snd_dtq(CanTx, requete.msg);    //send demendes
 	
 
-	rcv_dtq(CanRx, &reponse.msg);	//attente  reponse.msg
-	alpha = reponse.data.val;       //le val de angle de tourelle
+//	rcv_dtq(CanRx, &reponse.msg);	//attente  reponse.msg
+//	alpha = reponse.data.val;       //le val de angle de tourelle
 	
-	wai_flg (ev_periph,0x01,TWF_ORW,&flag);   //wait le potentiometre 0
-	c = periph[ADDR('R')].val;
-	clr_flg(ev_periph,0x01);		//clear flag
+	wai_flg (ev_periph,0x01,TWF_ANDW,&flag);   //wait reponse
+	alpha = periph[ADDR('R')].val;
 	
 	
-//	if(alpha > 900 ) a = 0;        // alpha >90° stop move
-	a = c - alpha;			// vitesse = consigne - position
+	
+
+	a = ad00 - alpha;			// vitesse = consigne - position	
+	if(alpha > 900 ) a = 0;        // alpha >90° stop move
 	comm.data.id = 'T';				// vitesse de tourelle
 	comm.data.rtr = 0;
 	comm.data.val = a;			//val de command est c-p
@@ -197,6 +204,53 @@
 	snd_dtq(CanTx, comm.msg);		//send command 
 	}	
 }
+
+void control_direct(){
+	CanFrame requete, reponse, comm;
+	FLGPTN flag;
+
+	while(1){	
+	requete.data.id = 'U';
+	requete.data.rtr = 1;			//indique une requête de lecture
+	periph[ADDR('U')].ev=0x02;		//event
+	snd_dtq(CanTx, requete.msg);	//send demande
+	
+//	rcv_dtq(CanRx, &reponse.msg);
+//	distance = reponse.data.val;
+
+	
+
+	wai_flg (ev_periph,0x02,TWF_ANDW,&flag);
+	distance = periph[ADDR('U')].val;
+	
+
+	comm.data.id = 'D';
+	comm.data.rtr = 0;
+	comm.data.val = ? -distance;
+	snd_dtq(CanTx, comm.msg);
+	}
+}
+
+void affiche(){
+	char str[20];
+
+	lcd_com(0xC0);
+	sprintf(str," %d ", distance);
+	lcd_str(str);
+}
+
+void vitesse(){
+	CanFrame comm;
+	while (1){
+
+	comm.data.id = 'V';
+	comm.data.rtr = 0;
+	comm.data.val = 10;
+	snd_dtq(CanTx, comm.msg);
+	}
+}
+		
+	
 /*
 void control_tourelle(){
 	// Q5 obtenir l'angle 
@@ -213,10 +267,10 @@
 	
 	
 	if(alpha > 900 ) a = 0;        // alpha >90° stop move
-	else a = 450 - alpha;			// vitesse = consigne - position
+	else a = ad00 - alpha;			// vitesse = consigne - position
 	comm.data.id = 'T';				// vitesse de tourelle
 	comm.data.rtr = 0;
-	comm.data.val = 2*a;			//val de command est c-p
+	comm.data.val = a;			//val de command est c-p
 	snd_dtq(CanTx, comm.msg);		//send command 
 	}	
 }
@@ -251,4 +305,5 @@
 	alpha = reponse.data.val;
 	}
 }
-*/
\ No newline at end of file
+*/
+
Index: branch/zhang/Emb_App/conf_noyau.cfg
===================================================================
--- branch/zhang/Emb_App/conf_noyau.cfg	(revision 204)
+++ branch/zhang/Emb_App/conf_noyau.cfg	(revision 205)
@@ -72,6 +72,25 @@
 	exinf	= 0x0;
 };
 
+task[]{
+	entry_address	= vitesse();
+	name	= ID_vitesse;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 2;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+task[]{
+	entry_address	= control_direct();
+	name	= ID_control_direct;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 2;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
@@ -110,8 +129,8 @@
 
 
 cyclic_hand[]{
-	entry_address	= acqui();
-	name	= ID_acqui;
+	entry_address	= affiche();
+	name	= ID_affiche;
 	exinf	= 0x0;
 	start	= OFF;
 	phsatr	= OFF;
@@ -119,8 +138,8 @@
 	phs_counter	= 0x0;
 };
 cyclic_hand[]{
-	entry_address	= asserv();
-	name	= ID_asserv;
+	entry_address	= acqui();
+	name	= ID_acqui;
 	exinf	= 0x0;
 	start	= OFF;
 	phsatr	= OFF;
@@ -129,6 +148,7 @@
 };
 
 
+
 vdataqueue[]{
 	name	= QdmTouche;
 	wait_queue	= TA_TFIFO;
