Index: branch/leroy/sp4c12/SP4c2/SP4c2.ARF
===================================================================
--- branch/leroy/sp4c12/SP4c2/SP4c2.ARF	(revision 860)
+++ branch/leroy/sp4c12/SP4c2/SP4c2.ARF	(revision 861)
@@ -1,5 +1,5 @@
 D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2.hws
 D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2\SP4c2.hwp
-D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2\SessionM32C_Simulator.hsf
 D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2\SessionM32C_E8a_SYSTEM.hsf
 D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2\DefaultSession.hsf
+D:\TP-SP4_LEROY_2021\sp4c12\SP4c2\SP4c2\SessionM32C_Simulator.hsf
Index: branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.ini
===================================================================
--- branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.ini	(revision 860)
+++ branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.ini	(revision 861)
@@ -25,4 +25,4 @@
 [Target]
 M32C E8a SYSTEM=Renesas Communications
 [USER_DATA]
-RESET=fe0000
+RESET=fe000a
Index: branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.hsf
===================================================================
--- branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.hsf	(revision 860)
+++ branch/leroy/sp4c12/SP4c2/SP4c2/SessionM32C_E8a_SYSTEM.hsf	(revision 861)
@@ -8,6 +8,7 @@
 "" 
 [GENERAL_DATA]
 "FIRST_CONNECTION_TAG" "NO" 
+"MRULABELS_DATAMANAGER_KEY" "FFFFFF|000000|882" 
 "RESET_CPU_AFTER_DOWNLOAD_TAG" "VARIANT_TRUE_STORE_TAG" 
 "{287A8023-99B5-49E1-A54E-4DDCA43D7959}MapCtrlECX_MAP_FIND_SYMBOL_LIST" "" 
 "{287A8023-99B5-49E1-A54E-4DDCA43D7959}MapCtrlViews" "0" 
@@ -28,9 +29,9 @@
 "{313F4FC1-6566-11D5-8BBE-0004E2013C71}TclTkCtrlLogFileName" "" 
 "{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_COMPARE_END_ADDRESS" "" 
 "{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_COMPARE_START_ADDRESS" "" 
-"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_DEST_ADDRESS" "" 
-"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_END_ADDRESS" "" 
-"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_START_ADDRESS" "" 
+"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_DEST_ADDRESS" "882" 
+"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_END_ADDRESS" "FFFFFF" 
+"{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_DISPLAY_START_ADDRESS" "000000" 
 "{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_FILL_END_ADDRESS" "" 
 "{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_FILL_START_ADDRESS" "" 
 "{313F4FC2-6566-11D5-8BBE-0004E2013C71}ECX_MEMORY_MOVE_END_ADDRESS" "" 
@@ -55,7 +56,7 @@
 "{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" "0000000000FE0000" 
+"{64753FED-D387-4B8C-A91D-D3419C869C07}C_REGISTER_REG_16" "0000000000FFFFFF" 
 "{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" 
@@ -93,7 +94,23 @@
 "{8A898260-6F1D-11D5-8EB6-00004CC34E9D}ECX_WAVE_COMB_BUFFER" ",,,," 
 "{8A898260-6F1D-11D5-8EB6-00004CC34E9D}ECX_WAVE_SAMPLING_RATE" "1000" 
 "{8A898260-6F1D-11D5-8EB6-00004CC34E9D}WaveformCtrlViews" "0" 
-"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersCtrlViews" "0" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersCtrlViews" "1" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0ColumnWidth" "51,64,37" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0ECX_REGISTER_COUNT" "36" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0ECX_REGISTER_DISPLAYED" "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0HideFLAGs" "0" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0HideRadix" "0" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0LastFileName" "" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWnd0RadixList" "16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,2,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16," 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndInstanceKey0" "{WK_00000001_REGISTERS}SP4c2SessionM32C_E8a_SYSTEM" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0ColumnWidth" "51,64,37" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0ECX_REGISTER_COUNT" "36" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0ECX_REGISTER_DISPLAYED" "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0HideFLAGs" "0" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0HideRadix" "0" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0LastFileName" "" 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewB0RadixList" "16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,2,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16," 
+"{95A081A1-7001-11D5-B1FD-00A0C9E23A58}RegistersWndViewBInstanceKey0" "{WK_00000001_REGISTERS}SP4c2SessionM32C_E8a_SYSTEMViewB" 
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ECX_IMAGE_ADDRESS_NAME" "" 
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ECX_IMAGE_BUFFER" "00000000,00000000,0,0" 
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ECX_IMAGE_COLOR" "0,0,0,0" 
@@ -104,8 +121,47 @@
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ECX_IMAGE_SAMPLEING_RATE" "1000" 
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ECX_IMAGE_VIEW" "0,0,0,0,0,0" 
 "{AC411480-6F0A-11D5-8EB6-00004CC34E9D}ImageCtrlViews" "0" 
-"{B266D880-6FA1-11D5-8613-00A024591A38}WatchCtrlViews" "0" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchCtrlViews" "4" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth0" "194" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth1" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth12" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth2" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ColWidth3" "200" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000" "sum, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0000_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001" "check_sum, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0001_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002" "check_sum_trame, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0002_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003" "c, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0003_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004" "c[0], 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0004_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005" "c[1], 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0005_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006" "check_sumT, 10, 0, P, Col, Hex, N" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEM0006_SCOPE" "Current Scope," 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd0ECX_WATCH_ITEMCnt" "7" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth0" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth1" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth12" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth2" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ColWidth3" "200" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd1ECX_WATCH_ITEMCnt" "0" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ColWidth0" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ColWidth1" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ColWidth12" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ColWidth2" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ColWidth3" "200" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd2ECX_WATCH_ITEMCnt" "0" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ColWidth0" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ColWidth1" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ColWidth12" "150" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ColWidth2" "120" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ColWidth3" "200" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWnd3ECX_WATCH_ITEMCnt" "0" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWndInitial_Radix" "0" 
+"{B266D880-6FA1-11D5-8613-00A024591A38}WatchWndInstanceKey0" "{WK_00000001_WATCH}SP4c2SessionM32C_E8a_SYSTEM" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWndRecentFile_WatchRecord" "" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWndRecentFile_WatchSave" "" 
 "{B266D880-6FA1-11D5-8613-00A024591A38}WatchWndUpdate_Interval" "100" 
@@ -675,9 +731,12 @@
 0 
 [WINDOW_POSITION_STATE_DATA_VD1]
 "Help" "TOOLBAR 0" 59419 1 5 "0.00" 0 0 0 0 0 17 0 "" "0.0" 
-"{WK_00000001_CmdLine}" "WINDOW" 59422 0 2 "0.10" 383 1600 -533 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
-"{WK_00000001_IO}SP4c2SessionM32C_E8a_SYSTEM" "WINDOW" 59422 0 1 "0.16" 383 0 0 350 200 18 0 "32817|32826|32819|32820|32821" "0.0" 
-"{WK_00000001_OUTPUT}" "WINDOW" 59422 0 0 "0.84" 383 534 287 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
+"{WK_00000001_CmdLine}" "WINDOW" 59422 0 2 "0.08" 383 1600 -533 350 200 17 0 "32771|32772|32778|<<separator>>|32773|32774|<<separator>>|32820|<<separator>>|32801|32824" "0.0" 
+"{WK_00000001_IO}SP4c2SessionM32C_E8a_SYSTEM" "WINDOW" 59422 0 1 "0.23" 383 0 0 350 200 18 0 "32817|32826|32819|32820|32821" "0.0" 
+"{WK_00000001_MEMORY}SP4c2SessionM32C_E8a_SYSTEM" "WINDOW" 59422 0 0 "0.33" 383 1600 -533 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.39" 383 534 287 350 200 18 0 "36756|36757|36758|36759|<<separator>>|36746|36747|<<separator>>|39531|<<separator>>|39500|39534|<<separator>>|36687" "0.0" 
+"{WK_00000001_REGISTERS}SP4c2SessionM32C_E8a_SYSTEM" "WINDOW" 59421 0 0 "1.00" 333 1600 -533 350 200 18 0 "" "0.0" 
+"{WK_00000001_WATCH}SP4c2SessionM32C_E8a_SYSTEM" "WINDOW" 59422 0 3 "0.38" 383 0 0 350 200 18 0 "32781|32783|<<separator>>|32771|32829|32772|32827|32773|<<separator>>|32786|<<separator>>|32810|32811|32831" "0.0" 
 "{WK_00000002_WORKSPACE}" "WINDOW" 59420 0 0 "1.00" 180 534 287 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" 
Index: branch/leroy/sp4c12/SP4c2/SP4c2/SP4c2.c
===================================================================
--- branch/leroy/sp4c12/SP4c2/SP4c2/SP4c2.c	(revision 860)
+++ branch/leroy/sp4c12/SP4c2/SP4c2/SP4c2.c	(revision 861)
@@ -1,12 +1,23 @@
-
 #include "sfr32c87.h"
 
 void uart0_init(void);
 void uart0_tx(char c);
 char uart0_rx(void);
-int rec_trame(char* trame);
+void irec_trame();
 int hex2int(char* c);
+void uart0_inter_init(); 
+char trame[200];
+int nombre_caractere = 0;
+	
+void uart0_inter_init(){
+	u0c1 = 0x15;
+	s0tic = 0x0F;
+	s0ric = 0x0F;
+	}
 
+int etat=1;
+int trame_ok = 0;
+
 void uart0_init(void){
 //Configuration des ports en entrée ou en sortie
 pd6_2 = 0; //RX en entrée
@@ -29,31 +40,64 @@
 
 }
 
-int rec_trame(char* trame){
-	int i = 1,trame_ok =0;
-	int check_sum=0;
-	char check_sum_trame[2];
+#pragma INTERRUPT 18 irec_trame
+
+void irec_trame(){
+	static int i = 0;
+	static int check_sum=0;
+	static char check_sum_trame[2];
 	char c;
 	
-while (uart0_rx() != '$'); //Tant qu'on ne reçoit pas le caratère quii indique le début de la trame, on attend
-while ((c = uart0_rx()) != '*'){//Reception des caracteres jusqu'à la fin de la trame
-	trame[i] = c;
-	check_sum ^= trame[i]; //Calcul du checksum de la trame reçue
-	i++;
-	}
+	c = uart0_rx();
 	
-	check_sum_trame[1] = uart0_rx(); //Acquisition du premier caractere du checksum
-	check_sum_trame[0] = uart0_rx();//Acquisition du deuxieme caractere du checksum
+	switch (etat){
+		case 1:
+			if (c == '$'){ //Tant qu'on ne reçoit pas le caratère qui indique le début de la trame, on attend
+				etat = 2;
+				check_sum=0;
+				i = 0;	
+			}
+		break;
+
+		case 2:
+		//Calcul du checksum
+			if (c != '*'){ //Tant qu'on ne reçoit pas le caratère qui indique la fin de la trame, on continue de recevoir les caractères
+				trame[i] = c;
+				check_sum ^= trame[i]; //Calcul du checksum de la trame reçue
+				nombre_caractere++;
+				i++;
+			}else{
+				etat = 3;
+				i = 0;
+			}			
+		break;
+		
+		case 3:
+			//Lecture des caractères correspondant au checksum
+			check_sum_trame[i] = c;
+			i++;
+			if (i == 2){ //Tant qu'on ne reçoit pas le caratère qui indique le début de la trame, on attend
+				etat = 4;			
+			}	
+		break;
+		
+		case 4:
+		//Comparaison(validation)
+			if (check_sum == hex2int(check_sum_trame)){
+				trame_ok = 1;
+				etat = 1;
+			}else{
+				trame_ok = 0;
+				etat = 1;		
+			}
+			uart0_tx(trame_ok);
+			uart0_tx(nombre_caractere);
+		break;
 	
+		}
+
+
 	
-	if (check_sum == hex2int(check_sum_trame)){
-		trame_ok = 1;
-	}else{
-		trame_ok = 0;		
-	}
-	uart0_tx(trame_ok);
-	
-	return i;
 }
 
 int hex2int(char* c){
@@ -69,9 +113,9 @@
 		}
 	}
 	
-	return(c[0] + 16* c[1]);
+	return(c[1] + 16* c[0]);
 	
-	}
+}
 
 void uart0_tx(char c){
 	while(ti_u0c1 != 1); //tant qu'il n'y a pas de donnée dans le registre de transmission
@@ -85,14 +129,18 @@
 
 int i;
 char trame[200];
-char buffer[200];
 
 void main(void)
 {	
 	uart0_init();
+	uart0_inter_init();
+	asm("FSET I");
+	while(1){
+		if (trame_ok == 1){	
+			trame_ok = 0; //Remise zéro de trame_ok dés que la réception de la trame s'est bien passée
+		}
 		
-	while(1){	
-	rec_trame(trame); //Reception de la trame
 	}
+	
 		
-}
+}
\ No newline at end of file
