Index: branch/noisette/Emb_App.tws
===================================================================
--- branch/noisette/Emb_App.tws	(revision 248)
+++ branch/noisette/Emb_App.tws	(revision 249)
@@ -12,9 +12,12 @@
 "E:\tp_info6_2018_noisette\tp_info6\bsp\dma0.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\lcd.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\uart0.c" 
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 
 [WORKSPACE_FILE_STATES]
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 0 0 790 335 0 7 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" -8 -30 956 523 1 1 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 0 0 956 523 0 0 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\can.c" 0 0 956 523 0 2 
@@ -22,6 +25,7 @@
 "E:\tp_info6_2018_noisette\tp_info6\bsp\dma0.c" 125 125 790 335 0 5 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\lcd.c" 150 150 790 335 0 6 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\periph.c" 75 75 790 335 0 3 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\uart0.c" 25 25 790 335 0 8 
 [LOADED_PROJECTS]
 "EmbM32C87App" 
 [END]
Index: branch/noisette/Emb_App/SessionM32C_E8a_system.hsf
===================================================================
--- branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 248)
+++ branch/noisette/Emb_App/SessionM32C_E8a_system.hsf	(revision 249)
@@ -142,7 +142,7 @@
 "{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_1" "0000000000000120" 
 "{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" "0000000000FF0578" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FF056C" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_17" "0000000000FFF800" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "00000000000009CC" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "00000000000007F6" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_18" "0000000000000C0C" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_19" "000000000000082E" 
 "{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_2" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_20" "0000000000000040" 
+"{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" 
@@ -173,7 +173,7 @@
 "{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_5" "0000000000000000" 
-"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "00000000000009F2" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_6" "0000000000000C2A" 
 "{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" 
@@ -205,7 +205,7 @@
 "{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" "alpha, 2, 0, P, Col, Dec, MA" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "alpha, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Global," 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "distance_tourelle, 1, 0, P, Col, Dec, MA" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
@@ -313,10 +313,12 @@
 [WINDOW_Z_ORDER]
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\crt0mr.a30" 
 "E:\tp_info6_2018_noisette\tp_info6\Emb_App\programme_principal_etud.c" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\uart0.c" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\periph.c" 
+"E:\tp_info6_2018_noisette\tp_info6\Emb_App\conf_noyau.cfg" 
+"E:\tp_info6_2018_noisette\tp_info6\bsp\can.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\dma0.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\clavier.c" 
-"E:\tp_info6_2018_noisette\tp_info6\bsp\periph.c" 
-"E:\tp_info6_2018_noisette\tp_info6\bsp\can.c" 
 "E:\tp_info6_2018_noisette\tp_info6\bsp\lcd.c" 
 [TARGET_NAME]
 "M32C E8a SYSTEM" "" 0 
@@ -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 100602392 1 "{00000000-0000-0000-C000-000000000046}" "" 
+"d:\profs\tp_info14_travail\tp_info14\emb_app\programme_principal_etud.c" 95 91165208 1 "{00000000-0000-0000-C000-000000000046}" "" 
 [END]
Index: branch/noisette/Emb_App/programme_principal_etud.c
===================================================================
--- branch/noisette/Emb_App/programme_principal_etud.c	(revision 248)
+++ branch/noisette/Emb_App/programme_principal_etud.c	(revision 249)
@@ -119,7 +119,7 @@
 //				disponible. 0xab avec a-> nombre de couleurs bien placées et b -> couleurs présentes mais mal placées.
 //'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 short alpha;
+int alpha;
 int consigne_tourelle;
 int consigne_distance;
 unsigned short k;
@@ -127,11 +127,61 @@
 int erreur_distance;
 int vitesse;
 int distance_tourelle;
-UINT flag;
+UINT flag;
+CanFrame comm, requete, reponse, req;
+
+void asserv_tourelle()
+{
+		while(1){
+			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);
+			alpha=periph[ADDR('R')].val;
+			k=2;
+			erreur_tourelle = 450 - alpha;
+			consigne_tourelle = k*erreur_tourelle;
+			comm.data.id= 'T';
+			comm.data.rtr=0;
+			comm.data.val=consigne_tourelle;
+			snd_dtq(CanTx, comm.msg);
+		}
+		dly_tsk(10);
+}
+
+void asserv_virage() {
+	while(1) {
+		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);
+		distance_tourelle=periph[ADDR('U')].val;
+		k = 12;
+		erreur_distance = 720 - distance_tourelle;
+		consigne_distance = k*erreur_distance;
+		consigne_distance = consigne_distance/10;
+		comm.data.id= 'D';
+		comm.data.rtr=0;
+		comm.data.val=-consigne_distance;
+		snd_dtq(CanTx, comm.msg);
+		dly_tsk(10);
+	}	
+}
+
+void command(vitesse){
+		comm.data.id= 'V';
+		comm.data.rtr=0;
+		comm.data.val=vitesse;
+		snd_dtq(CanTx, comm.msg);
+		dly_tsk(10);
+}
+
 void main()
 {
 
-	CanFrame comm, requete, reponse, req;
+	
 	ports_mcu();
     lcd_init();
 	periph_init();
@@ -142,7 +192,12 @@
 	capture_init();
 
 	sta_cyc(ID_acqui);
-	sta_tsk(ID_periph_rx);
+	sta_tsk(ID_periph_rx);
+	sta_tsk(ID_asserv_tourelle);
+	
+	dly_tsk(2500);
+	sta_tsk(ID_asserv_virage);
+	
 
     while(1)
     {
@@ -151,64 +206,9 @@
 		LED_J=0;
 		dly_tsk(100);
 		
-		/*comm.data.id= 'T';
-		comm.data.rtr=0;
-		comm.data.val=100;
-		snd_dtq(CanTx, comm.msg);
-		dly_tsk(10);
-		comm.data.id= 'T';
-		comm.data.rtr=0;
-		comm.data.val=0;
-		snd_dtq(CanTx, comm.msg);
-		requete.data.id='R';
-		requete.data.rtr=1;
-		snd_dtq(CanTx, requete.msg);
 		
-		rcv_dtq(CanRx, &reponse.msg);
-		alpha=reponse.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);
-		alpha=periph[ADDR('R')].val;
-		
-		dly_tsk(10);
-		
-		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);
-		distance_tourelle=periph[ADDR('U')].val;
-		
-		dly_tsk(10);
-		
-		/*requete.data.id='U';
-		requete.data.rtr=1;
-		snd_dtq(CanTx, requete.msg);
-		
-		rcv_dtq(CanRx, &reponse.msg);
-		distance_tourelle=reponse.data.val;*/
-		
-		comm.data.id= 'T';
-		comm.data.rtr=0;
-		comm.data.val=asserv_tourelle(450);
-		snd_dtq(CanTx, comm.msg);
-		dly_tsk(50);
-		
-		comm.data.id= 'V';
-		comm.data.rtr=0;
-		comm.data.val=10;
-		snd_dtq(CanTx, comm.msg);
-		dly_tsk(10);
-		
-		comm.data.id= 'D';
-		comm.data.rtr=0;
-		comm.data.val=-asserv_virage(719);
-		snd_dtq(CanTx, comm.msg);
-		dly_tsk(10);
-		
+
+		command(50);
 		
     }
 }
@@ -218,24 +218,9 @@
 	LED_V=!LED_V;
 }
 
-int asserv_tourelle(consigne_tourelle)
-{
-		k=1;
-		erreur_tourelle = consigne_tourelle - alpha;
-		consigne_tourelle = k*erreur_tourelle;
-		return consigne_tourelle;
-}
 
 
-int asserv_virage(consigne_distance) {
-		if (alpha==450) 
-		k = 3;
-		erreur_distance = consigne_distance - distance_tourelle;
-		consigne_distance = k*erreur_distance;
-		consigne_distance = consigne_distance/10;
 		
-		return consigne_distance;
-}
 
 
 
Index: branch/noisette/Emb_App/conf_noyau.cfg
===================================================================
--- branch/noisette/Emb_App/conf_noyau.cfg	(revision 248)
+++ branch/noisette/Emb_App/conf_noyau.cfg	(revision 249)
@@ -43,7 +43,28 @@
 	initial_start	= ON;
 	exinf	= 0x0;
 };
+
 task[]{
+	entry_address	= asserv_tourelle();
+	name	= ID_asserv_tourelle;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 3;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
+	entry_address	= asserv_virage();
+	name	= ID_asserv_virage;
+	stack_size	= 256;
+	stack_section	= stack;
+	priority	= 3;
+	initial_start	= OFF;
+	exinf	= 0x0;
+};
+
+task[]{
 	entry_address	= periph_tx();
 	name	= ID_periph_tx;
 	stack_size	= 256;
@@ -62,6 +83,7 @@
 	exinf	= 0x0;
 };
 
+
 flag[]{
 	name	= ev_bus_fin_tr;
 	initial_pattern	= 0x0000;
