Bonjour,

j'ai un drôle de problème qui concerne encore un sujet sur l'eeprom,
voila je fait une ecriture a des adresses d'eeprom
et je faits une lecture à l'initialisation des datas se trouvant à ces
adresses puis je fait un printf des datas mais ça ne correspond pas après le reset
du microcontrolleur, pourquoi pourtant mon code semble logique ?


voici la capture après le reset:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
 
Relisez les priorités attribuées puis corriger
 Priority MIC >> PA set to : 1Ah
Priority GUI >> PA set to : 3h
Priority RAD >> PA set to : 3h
Priority AUX >> PA set to : 2h
Priority IN1 set to : 2h
Priority IN2 set to : 6h
Priority IN3 set to : 6h
Read 1
Write 1
CS0 1
CS1 1
CS0 0
CS1 1
AO 1
A1 1
A2 1
PIO_PWR 0
PIO_RESET 0
-> Please press any key to exit
voici la capture lors de la configuration, ecriture:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
 
Relisez les priorités attribuées puis corriger
 Priority MIC >> PA set to : 3h
Priority GUI >> PA set to : 4h
Priority RAD >> PA set to : 2h
Priority AUX >> PA set to : 5h
Priority IN1 set to : 6h
Priority IN2 set to : 7h
Priority IN3 set to : 8h
Read 1
Write 1
CS0 1
CS1 1
CS0 0
CS1 1
AO 1
A1 1
A2 1
PIO_PWR 0
PIO_RESET 0
-> Please press any key to exit
Les fonctions basiques :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
/**********************************************************************************
Function: EEP2408_write_byte
***********************************************************************************/
void EEP2408_write_byte(unsigned char MyByte1, unsigned char MyByte2)
{
  I2C_TEA6320 = 0;
  I2C_PCF8574 = 0;
  I2C_EEPwrit = 1;	
  I2C_EEPread = 0;
 
  EA = 1;
  I2C_Byte1 = MyByte1; 				// Word Address
  I2C_Byte2 = MyByte2; 				// Data
  I2C_Status = I2C_BUSY;  			// I2C is now busy
  SSCON = 0xC0; 					// enable I2C - no acknowledgements will be generated
  SSCON = SSCON | 0x20; 			// request to transmit a start condition 
 
  while(I2C_Status == I2C_BUSY); 	// wait until I2C is no longer busy
  SSDAT = 0xFF;		//re-init SSDAT
}
 
/**********************************************************************************
Function: EEP2408_read_byte
***********************************************************************************/
void EEP2408_read_byte(unsigned char MyByte1)
{
  I2C_TEA6320 = 0;
  I2C_PCF8574 = 0;
  I2C_EEPwrit = 0;	
  I2C_EEPread = 1;
 
  EA = 1;
  I2C_Byte1 = MyByte1; 				// Word Address
  I2C_Status = I2C_BUSY;  			// I2C is now busy
  SSCON = 0xC0; 					// enable I2C - no acknowledgements will be generated
  SSCON = SSCON | 0x20; 			// request to transmit a start condition 
 
  while(I2C_Status == I2C_BUSY); 	// wait until I2C is no longer busy
  SSDAT = 0xFF;		//re-init SSDAT
}


La fonction à l'initialisation et où je suis sur que le programme passe (test1 = 0 à l'init):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
 
 
void init_priority(void)
{
if (Test1 == 0)
        {
        EEP2408_ADDRESS = 0x05;
		EEP2408_read_byte(EEP2408_ADDRESS);
 
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
    	prior_MicDrive = EEP_READ;
		pm = EEP_READ;
 
        EEP2408_ADDRESS = 0x06;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_MicGui = EEP_READ;
		pg = EEP_READ;
 
        EEP2408_ADDRESS = 0x07;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_Rad = EEP_READ;
		pr = EEP_READ;
 
        EEP2408_ADDRESS = 0x08;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_Aux = EEP_READ;
		pa = EEP_READ;
 
        EEP2408_ADDRESS = 0x09;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_IN1 = EEP_READ;
		pIN1 = EEP_READ;
 
        EEP2408_ADDRESS = 0x0A;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_IN2 = EEP_READ;
		pIN2 = EEP_READ;
 
        EEP2408_ADDRESS = 0x0B;
		EEP2408_read_byte(EEP2408_ADDRESS);
		#ifdef DEBUG_ME2   //testali0304
		printf("\n");
        #endif            //testali0304
		prior_IN3 = EEP_READ;
		pIN3 = EEP_READ;
 
		}
		Test1 = 1;
 
}
la fonction pour afficher les datas :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
/*************************************************************************************
Function: debug_prior
Remarque: Pémermet de débuger des erreurs à l'attribution des priorités
**************************************************************************************/
void debug_prior(void)
{
   #ifdef DEBUG_MEPrior   //testali0304
   printf ("Relisez les priorités attribuées puis corriger\n\r ");
   printf ("Priority MIC >> PA set to : %Xh\n\r",prior_MicDrive);
   printf ("Priority GUI >> PA set to : %Xh\n\r",prior_MicGui);
   printf ("Priority RAD >> PA set to : %Xh\n\r",prior_Rad);
   printf ("Priority AUX >> PA set to : %Xh\n\r",prior_Aux);
   printf ("Priority IN1 set to : %Xh\n\r",prior_IN1);
   printf ("Priority IN2 set to : %Xh\n\r",prior_IN2);
   printf ("Priority IN3 set to : %Xh\n\r",prior_IN3);
   #endif            //testali0304
 
    Read = P3_7;
    Write = P3_6;
 
    MIC = P1_0;
    RAD = P1_1;
    C_select1 = P5_2;  //0605 re
    C_select2 = P5_3;  //0605 re
    A_O = P0_0;
    A_1 = P0_1;
    A_2 = P0_2;
    PIO_WR = P5_0;
    PIO_RESET = P4_2;  //0605 re
 
   #ifdef DEBUG_MEPrior   //testali0304
	printf("Read %X\n",Read);
    printf("Write %X\n", Write);
    printf("CS0 %X\n", CS0);
    printf("CS1 %X\n", CS1);
    printf("CS0 %X\n", C_select1);  //0605 ajout
    printf("CS1 %X\n", C_select2);  //0605 ajout
 
    printf("AO %X\n", A_O);
    printf("A1 %X\n", A_1);
    printf("A2 %X\n", A_2);
    printf("PIO_PWR %X\n", PIO_WR);
    printf("PIO_RESET %X\n", PIO_RESET);
   #endif            //testali0304
 
}


Enfin les routines du menu pour voir et configurer les priorités donc
pour ecrire dans l'eeprom.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
 
 
// r: To read priority
	if (STR_IN[31]==0x72)/*||(STR_IN[31]==0x6F))*/
	{
        debug_prior();
		Menu_Flag=0;
#ifdef DEBUG_MEPrior    //testali0304
		printf("-> Please press any key to exit\n");
#endif            //testali0304
 
		for (j=0;j<32;j++) STR_IN[j]=STR_IN[j+1];
		STR_IN[31]=getchar0();
#ifdef DEBUG_MEPrior    //testali0304
	  	printf("%c\n",STR_IN[31]);
#endif            //testali0304
	}
 
// Q: Change Priority 
if (STR_IN[31]==0x51) /*||(STR_IN[31]==0x71))*/
{
#ifdef DEBUG_MEPrior    //testali0304
printf ("\nVeillez suivre les intructions SVP\n\r"); 
printf ("\n!CAUTION: Les priorités sont comprises entre 02-->08 inclus \n\r");
#endif            //testali0304
ordre = 1;
              do
			  {
 if (ordre == 1)
 { 
ordre = 2;
prior_cond = 0x00;
EEP2408_ADDRESS = 0x05;
#ifdef DEBUG_MEPrior    //testali0304
printf("La priorité actuel du MIC >> PA est : %Xh\n",prior_MicDrive);
printf("Introsuisez l'ordre de priorité pour MIC >> PA + <INTER>\n");
#endif            //testali0304
		do		
		{
			for (j=0;j<32;j++) STR_IN[j]=STR_IN[j+1];
			STR_IN[31]=getchar0();
#ifdef DEBUG_MEPrior    //testali0304
		  	printf("%c",STR_IN[31]);
#endif            //testali0304
 
		}
		while (STR_IN[31]!=0x0D);
#ifdef DEBUG_MEPrior    //testali0304
	  	printf("\n\r");
#endif            //testali0304
 
		switch (STR_IN[29]) 
 	    {
			case 0x30:EEP2408_VALUE = 0x00; break;
			default:
#ifdef DEBUG_MEPrior    //testali0304
		            printf("ERROR WRONG PRIORITY Please Try again!\n\r");
#endif            //testali0304
 
                    ordre = 1;
					EEP2408_VALUE = 0xEE;
					prior_cond = 0x01;
			break;
		}
 
		  if ( STR_IN[29] == 0x30)
		  {
		switch (STR_IN[30])
 	    {
			case 0x32:EEP2408_VALUE+= 0x02; break;
			case 0x33:EEP2408_VALUE+= 0x03; break;
			case 0x34:EEP2408_VALUE+= 0x04; break;
			case 0x35:EEP2408_VALUE+= 0x05; break;
			case 0x36:EEP2408_VALUE+= 0x06; break;
			case 0x37:EEP2408_VALUE+= 0x07; break;
			case 0x38:EEP2408_VALUE+= 0x08; break;
			default: 
#ifdef DEBUG_MEPrior    //testali0304
		            printf("ERROR WRONG PRIORITY Please Try again!\n\r");
#endif            //testali0304
 
                    ordre = 1;
					EEP2408_VALUE = 0xEE;
					prior_cond = 0x01;
			break;
		}
#ifdef DEBUG_MEPrior    //testali0304
printf(" DATA %Xh\n",EEP2408_VALUE);
#endif            //testali0304
 
prior_MicDrive = EEP2408_VALUE;
pm = EEP2408_VALUE; // WARNING CHAR >< INT
Menu_Flag=0;
EEP2408_write_byte(EEP2408_ADDRESS,EEP2408_VALUE); // Ecrit dans le EEPROM à l'adresse 05
 
    }
 }
 
 if (ordre == 2)
 { 
ordre = 3;
prior_cond = 0x00;
EEP2408_ADDRESS = 0x06;
#ifdef DEBUG_MEPrior    //testali0304
printf("La priorité actuel du GUIDE >> PA est : %Xh\n",prior_MicGui);
printf("Introsuisez l'ordre de priorité pour GUIDE >> PA + <INTER>\n");
#endif            //testali0304
 
		do		
		{
			for (j=0;j<32;j++) STR_IN[j]=STR_IN[j+1];
			STR_IN[31]=getchar0();
#ifdef DEBUG_MEPrior    //testali0304
		  	printf("%c",STR_IN[31]);
#endif            //testali0304
 
		}
		while (STR_IN[31]!=0x0D);
#ifdef DEBUG_MEPrior    //testali0304
	  	printf("\n\r");
#endif            //testali0304
 
		switch (STR_IN[29]) 
 	    {
			case 0x30:EEP2408_VALUE = 0x00; break;
			default: 
#ifdef DEBUG_MEPrior    //testali0304
		            printf("ERROR WRONG PRIORITY Please Try again!\n\r");
#endif            //testali0304
                    ordre = 2;
					EEP2408_VALUE = 0xEE;
					prior_cond = 0x01;
			break;
		}
 
		  if ( STR_IN[29] == 0x30)
		  {
		switch (STR_IN[30])
 	    {
			case 0x32:EEP2408_VALUE+= 0x02; break;
			case 0x33:EEP2408_VALUE+= 0x03; break;
			case 0x34:EEP2408_VALUE+= 0x04; break;
			case 0x35:EEP2408_VALUE+= 0x05; break;
			case 0x36:EEP2408_VALUE+= 0x06; break;
			case 0x37:EEP2408_VALUE+= 0x07; break;
		    case 0x38:EEP2408_VALUE+= 0x08; break;
			default: 
#ifdef DEBUG_MEPrior    //testali0304
		            printf("ERROR WRONG PRIORITY Please Try again!\n\r");
#endif            //testali0304
 
                    ordre = 2;
					EEP2408_VALUE = 0xEE;
					prior_cond = 0x01;
			break;
		}
#ifdef DEBUG_MEPrior    //testali0304
printf(" DATA %Xh\n",EEP2408_VALUE);
#endif            //testali0304
 
prior_MicGui = EEP2408_VALUE;
pg = EEP2408_VALUE; // WARNING CHAR >< INT
Menu_Flag=0;
EEP2408_write_byte(EEP2408_ADDRESS,EEP2408_VALUE); // Ecrit dans le EEPROM à l'adresse 06
if (prior_MicDrive == prior_MicGui)
   {
   ordre = 2;
   prior_cond1 = 0x01;
#ifdef DEBUG_MEPrior    //testali0304
   printf("ERROR!!La Priorité %X déjà Attribuée!! Please Try again!\n\r",EEP2408_VALUE);
#endif            //testali0304
   }
else {prior_cond1 = 0x00;}
 
    }
 }
 
  if (ordre == 3)
 { 
ordre = 4;
prior_cond = 0x00;
EEP2408_ADDRESS = 0x07;
#ifdef DEBUG_MEPrior    //testali0304
printf("La priorité actuel du RAD >> PA est : %Xh\n",prior_Rad);
printf("Introsuisez l'ordre de priorité pour RAD >> PA + <INTER>\n");
#endif            //testali0304
		do		
		{
			for (j=0;j<32;j++) STR_IN[j]=STR_IN[j+1];
			STR_IN[31]=getchar0();
#ifdef DEBUG_MEPrior    //testali0304
		  	printf("%c",STR_IN[31]);
#endif            //testali0304
		}
		while (STR_IN[31]!=0x0D);
 
......

Pouvez vous dire la raison pour laquelle la capture après
le reset n'est pas la même?

Merci