Page 1 sur 1

Soucis Prog I2C

Publié : 08 mars 2007 16:51
par Makia
Bonjours a tous , j'ai un soucis au niveau de l'I2C.
J'ecris dans une EEPROM 24c08 jusqu'a l'adresse 996.
Le prob c'est que quand je li se que j'ai ecris ca ne me donne pas les meme valeur s.

Code : Tout sélectionner

Ici j'ecris de l'adresse 6 a 996 .


void Affichage_Send_Vr()
 {
 
 Send_Uart_Ray_VCons();

    for(adr = 6 ; adr <997;adr = adr+4)
      {
        Conv_AdcToASCII(2);
        LCD_Chr(2,7,VReel[1]);
        LCD_Chr(2,8,VReel[2]);
        LCD_Chr(2,9,',');
        LCD_Chr(2,10,VReel[3]);

        I2C_Start();
        I2C_Wr(0xA2);
        I2C_Wr(Adr);
        I2C_Wr(VReel[1]);
        I2C_Wr(VReel[2]);
        I2C_Wr(VReel[3]);
        I2C_Stop();

 Delay_ms(50);
 
  }

La je lis les meme adresses .

 for(adr = 6 ; adr <997;adr = adr+4)
      {
Conversion4(Adr);
 Soft_UART_Write(Tampon[1]);
 Soft_UART_Write(Tampon[2]);
 Soft_UART_Write(Tampon[3]);
 Soft_UART_Write(' ');

 I2C_Start();                                  
 I2C_Wr(0xA2);                             
 I2C_Wr(adr);                               
 I2C_Repeated_Start();
 I2C_Wr(0xA3);

 Soft_UART_Write(I2C_Rd(1));       //Lecture et envoi Envoi RS232
 Soft_UART_Write(I2C_Rd(1));
 Soft_UART_Write('.');
 Soft_UART_Write(I2C_Rd(0));
 I2C_Stop();

 Soft_UART_Write(' ');
 Soft_UART_Write('c');
 Soft_UART_Write('m');
 Soft_UART_Write('/');
 Soft_UART_Write('m');
 Soft_UART_Write('i');
 Soft_UART_Write('n');
 Soft_UART_Write(10);
 Soft_UART_Write(13);

 
}

}

C'est un echantillon de mon programme ne soiyez pas etonné si vous ne voyais aucun declaration de variables et de fonctions.
Avec se code je n'obtient pas les bon résultats , alors qu'avec celui ci oui :

Code : Tout sélectionner

void Affichage_Send_Vr()
 {
 
 Send_Uart_Ray_VCons();

    for(adr = 6 ; adr <997;adr = adr+4)
      {
        Conv_AdcToASCII(2);
        LCD_Chr(2,7,VReel[1]);
        LCD_Chr(2,8,VReel[2]);
        LCD_Chr(2,9,',');
        LCD_Chr(2,10,VReel[3]);

        I2C_Start();
        I2C_Wr(0xA2);
        I2C_Wr(Adr);
        I2C_Wr(VReel[1]);
        I2C_Wr(VReel[2]);
        I2C_Wr(VReel[3]);
        I2C_Stop();

 Delay_ms(50);
 
 Conversion4(Adr);
 Soft_UART_Write(Tampon[1]);
 Soft_UART_Write(Tampon[2]);
 Soft_UART_Write(Tampon[3]);
 Soft_UART_Write(' ');

 I2C_Start();
 I2C_Wr(0xA2);
 I2C_Wr(adr);
 I2C_Repeated_Start();
 I2C_Wr(0xA3);

 Soft_UART_Write(I2C_Rd(1));
 Soft_UART_Write(I2C_Rd(1));
 Soft_UART_Write('.');
 Soft_UART_Write(I2C_Rd(0));
 I2C_Stop();

 Soft_UART_Write(' ');
 Soft_UART_Write('c');
 Soft_UART_Write('m');
 Soft_UART_Write('/');
 Soft_UART_Write('m');
 Soft_UART_Write('i');
 Soft_UART_Write('n');
 Soft_UART_Write(10);
 Soft_UART_Write(13);

 Send_PCF(Calc_Err());
  }
//*/
   }
La difference entre les deux codes sont tres minces , je ne comprend pas pourquoi ca ne fonctionne pas .
SI quelqu'un sais pourquoi , qu'il me fasse signe .
Merci.