Index: branch/Antourou/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/Antourou/Emb_App/SessionM32C_E8a_system.hsf	(revision 344)
+++ branch/Antourou/Emb_App/SessionM32C_E8a_system.hsf	(revision 345)
@@ -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" "000000000000030C" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_1" "0000000000004993" 
+"{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" 
@@ -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" "0000000000FF46C9" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000001092" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "0000000000000822" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000101" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "00000000000000C1" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF00E7" 
+"{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" "0000000000000826" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000001" 
 "{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,11 +169,11 @@
 "{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" "0000000000003E70" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000003212" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000010C0" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_4" "0000000000FF000A" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_5" "0000000000000512" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000826" 
 "{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" 
@@ -279,14 +279,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 3 "0.08" 300 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 3 "0.07" 300 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.15" 300 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.03" 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 1 "0.60" 300 0 0 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
+"{WK_00000001_OUTPUT}" "WINDOW" 59422 0 1 "0.69" 300 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.08" 300 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 2 "0.17" 300 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 2 "0.08" 300 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" 
@@ -312,8 +312,8 @@
 [WINDOW_POSITION_STATE_DATA_VD4]
 [WINDOW_Z_ORDER]
 "E:\tp_info6_2016_antourou\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2016_antourou\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2016_antourou\Emb_App\conf_noyau.cfg" 
-"E:\tp_info6_2016_antourou\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2016_antourou\bsp\can.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
@@ -361,5 +361,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 96007752 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 96212584 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/Antourou/Emb_App/programme_principal_etud.c
===================================================================
--- branch/Antourou/Emb_App/programme_principal_etud.c	(revision 344)
+++ branch/Antourou/Emb_App/programme_principal_etud.c	(revision 345)
@@ -27,9 +27,9 @@
 #include "carte_m32.h"
 #include <math.h>
 //unsigned int vf;
-//	CanFrame comm;
-//	CanFrame requete;
-//	UINT flag;//FLGPTN flag
+	CanFrame comm;
+	CanFrame requete;
+	UINT flag;//FLGPTN flag
 //	short position, distance; // valeur de l'angle renvoyée par le simulateur
 //
 
@@ -133,95 +133,57 @@
 4: changer asserv_tourelle: enlever les //rcv_dtq(CanRx, &repon.msg);
 5: dupliquer la tâche 'R' en 'V' 
 et 'T' en 'D'
+*/
 
+// fonction du programme:                        
+void acquivitessetourelle(int vitesse);// acquisition de la vitesse de la tourelle
+unsigned short acquipositiontourelle();// acquisition de la position de la tourelle
+unsigned short longeurtel();// acquisition de la distance mesuré par le télemètre
+unsigned short mesuredistance();// lecture de la distance des roues au mur
+void Avancementvoit(int vitesse);// vitesse de la voiture en r/s
+void rouedirectrices(unsigned short angleroue);//angle des roues en 10e de degre
+void Asservissment_tourelle();// asservissment de la tourelle
 
 
-/*short alpha;
-void vitessedelatourelle(  int vit)
-{
-		// commander la vitesse de rotation de la tourelle
-		comm.data.id='T'; 
-		comm.data.rtr=0;
-		comm.data.val= vit;
-		snd_dtq (CanTx,comm.msg);
-		dly_tsk(100);
-}
-*/
+unsigned short alpha;
+unsigned short distancemesure;
 
-void asserv_tourelle();
-void regul_roue();
-void Avancementvoit();
-void acqui();
-
-unsigned short distance, longtourn, alpha,angleroue;
-void main()
-{
-        CanFrame req,reponse,comm;
-        ports_mcu();
-   		lcd_init();
-        periph_init();
-        periph_nom("#TEST001*");
-    	can_init();
-    	clavier_init(1);
-        capture_init(); 
-        
-        
-        sta_cyc(ID_acqui);// //Var g utlisées par les asservissements
-        sta_tsk(ID_periph_rx);
-        sta_tsk(ID_asserv_tourelle);
- 		Avancementvoit();
-	 	sta_tsk(ID_regul_roue);
-		
-        
-        
-    while(1)
-    {
+// commande de la tourelle+acquisition de la distance avec le télémètre
+unsigned short acquipositiontourelle()
+{				
+                CanFrame requete ;
+                UINT flag ;        
                 
-                LED_J=1;
-                dly_tsk(100);
-                LED_J=0;
-                dly_tsk(100);
-    }
-        
-}
-void acqui()
-{
-        LED_V=!LED_V;
-}	
-
-void asserv_tourelle()
-{		// asservissement de la tourelle vérifié  (ne pas toucher)      
-        
-                CanFrame req,repon,comm;
-                UINT flag;        
-                while(1)
-                {       //acquisition de l'angle mesurée par la tourelle  
-                        req.data.id='R'; //angle de la tourelle
-                        req.data.rtr=1; //req de lecture
-                        snd_dtq(CanRx, req.msg);
-        
-                        //rcv_dtq(CanRx, &repon.msg);
+                      //acquisition de l'angle mesurée par la tourelle  
+                        requete.data.id='R'; //angle de la tourelle
+                        requete.data.rtr=1; //req de lecture
+                        snd_dtq(CanRx, requete.msg);
+						//rcv_dtq(CanRx, &repon.msg);
                         periph[ADDR('R')].ev=0x01;
-                        snd_dtq(CanTx,req.msg);
+                        snd_dtq(CanTx,requete.msg);
                         wai_flg(ev_periph, 0x01, TWF_ANDW,&flag);
-                        alpha=periph[ADDR('R')].val;
-                        
+						alpha=periph[ADDR('R')].val;
+						return alpha;
+			
+ 
+}                        
+void acquivitessetourelle(int vitessetourelle)
+{						int vitessetourelle;
                         //asservissement de  la tourelle
-                        comm.data.id='T'; // vitesse de la tournelle
-                        comm.data.rtr=0;
-                        comm.data.val=450-alpha; 
+                        comm.data.id='T'; 
+                        comm.data.rtr=0;// commande d'écriture
+                        comm.data.val=vitessetourelle;
                         snd_dtq(CanTx,comm.msg);
                         dly_tsk(100);
-                }        
+                       
                 
 }
-unsigned short longeurtourelle()// acquisition de la distance mesuré par le télemètre
+unsigned short longeurtel()// acquisition de la distance mesuré par le télemètre
 { 				
-				CanFrame req, repon ;
+				CanFrame req, longtourn ;
 				int distancecons,k;
                 UINT flag;
-				
-                req.data.id='U'; 
+				req.data.id='U'; 
                 req.data.rtr=1; //requ de lecture
                 snd_dtq(CanRx, req.msg);
                 //rcv_dtq(CanRx, &repon.msg);
@@ -228,49 +190,101 @@
               	periph[ADDR('U')].ev=0x02;
              	snd_dtq(CanTx,req.msg);
               	wai_flg(ev_periph, 0x02, TWF_ANDW,&flag);
-            	longtourn=periph[ADDR('U')].val; 
-				return longtourn;
+            	return periph[ADDR('U')].val; 
+				
 }
-unsigned short mesuredistance()
+unsigned short distanceaumur()// lecture de la distance des roues au mur
 {
-				unsigned short distance;
-				distance=longtourn * sin( 3,14 * (alpha/10) * 180 );
+				unsigned short distance, longtourn,alpha;
+				distance=longtourn * sin( 3,14 * (alpha/10) * 180.0 );
 				return distance;
 }
-void rouedirectrices(unsigned short angleroue)
-{
+void rouedirectrices(unsigned short angleroue)//angle des roues en 10e de degre
+{	
         		CanFrame comm;
-				comm.data.id = 'D';
+				comm.data.id = 'D';// 
         		comm.data.rtr = 0; //ecriture
-        		comm.data.val = angleroue;
+        		comm.data.val = angleroue;// écriture dans angleroue la valeur de l'angle des roues directrices
         		snd_dtq (CanTx,comm.msg);
 				
 }
+void Avancementvoit()   //(ne pas toucher)// vitesse du véhicule
+{
+        	CanFrame requete;
+        	requete.data.id='V';
+        	requete.data.rtr=0;
+        	requete.data.val=30;// valeur de la vitesse
+        	snd_dtq(CanTx,requete.msg);
+        
+}
+void Asservissment_tourelle()// asservissment de la tourelle
+{
+	unsigned short  pos_tourelle;
+	int k, vites;
+	k=3;
+	while(1)
+        {
+                pos_tourelle = acquipositiontourelle();         
+                vites = k*( 450 - pos_tourelle);  //correcteur Prop
+                acquivitessetourelle(vites);
+				
+                dly_tsk(100);
+        }	
+} 
 void regul_roue()
-{// asservissment véh
-				int distancecons,k,distancemesure;
-           		distancecons=mesuredistance();
-				k=1;// gain pour asservissement      
-                while(1)
+{ //asservissment véh
+				
+				int k, distancecons;
+				int angleroue;
+			 	k=3;// gain pour asservissement 
+           		distancecons=500;
+				while(1)
                 {     
-                 	distancemesure=mesuredistance();
-					angleroue=-k*(distancecons-distancemesure);
-					rouedirectrices(angleroue);       
-                }
-}
-      
-void Avancementvoit() // voiture avance avec la vitesse voulue  (ne pas toucher)
+                 	distancemesure=distanceaumur();
+					angleroue=-k*(distancecons-distancemesure);// correction
+					rouedirectrices(angleroue);
+					    
+					dly_tsk(25);
+                }						
+}          
+
+void main ()
 {
-        CanFrame requete;
-		 dly_tsk(5000);
-        requete.data.id='V';
-        requete.data.rtr=0;
-        requete.data.val=30;// valeur de la vitesse
-        snd_dtq(CanTx,requete.msg);
+        CanFrame requete,reponse,comm;
+        ports_mcu();
+   		lcd_init();
+        periph_init();
+        periph_nom("#TEST001*");
+    	can_init();
+    	clavier_init(1);
+        capture_init(); 
         
+        
+        sta_cyc(ID_acqui);// //Var g utlisées par les asservissements
+        sta_tsk(ID_periph_rx);
+       	Avancementvoit();
+		sta_tsk(ID_Asservissment_tourelle);
+	
+ 		sta_tsk(ID_regul_roue);
+	
+		
+        
+        
+    while(1)
+    {
+                 
+                LED_J=1;
+                dly_tsk(100);
+                LED_J=0;
+                dly_tsk(100);
+    }
+        
 }
-        
 
+void acqui()
+{
+        LED_V=!LED_V;
+}
 
 
 
Index: branch/Antourou/Emb_App/conf_noyau.cfg
===================================================================
--- branch/Antourou/Emb_App/conf_noyau.cfg	(revision 344)
+++ branch/Antourou/Emb_App/conf_noyau.cfg	(revision 345)
@@ -62,8 +62,8 @@
 	exinf	= 0x0;
 };
 task[]{
-	entry_address	= asserv_tourelle();
-	name	= ID_asserv_tourelle;
+	entry_address	= Asservissment_tourelle();
+	name	= ID_Asservissment_tourelle;
 	stack_size	= 256;
 	stack_section	= stack;
 	priority	= 6;
