mainenant ça fonctionne, le LM92 n'avait pas le temps pour convertir, il fallait mettre au min 1 sec. (dans le while(true)).
Mainenant je vais faire avec les variables signées,
Code:#define ADDRESS_LM92_READ 0x91 // lm92 addresse de lecture #define ADDRESS_LM92_WRITE 0x90 // lm92 addresse d'écriture #define SET_POINTER_REGISTER_TEMP 0x00 // adresse du pointeur register Temperature (Read only) #define SET_POINTER_REGISTER_CONFIG 0x01 // adresse du pointeur register Configuration(Read/Write) #define CONFIGURATION_STD 0x00 // configuration #define lm92_manufacturer_id 0x07 // ID manufacturer //--------------------------------------------------------------------- // Variable Globale //--------------------------------------------------------------------- int temp_msb , temp_lsb; int Manufacturer_ID_msb, Manufacturer_ID_lsb; //int LM92_temp_data; //--------------------------------------------------------------------- // Fonctions //--------------------------------------------------------------------- // Fonction configuration void write_in_configuration_register(int config) { i2c_start(); // start i2c_write(ADDRESS_LM92_WRITE); // adresse du LM92 en écriture i2c_write(SET_POINTER_REGISTER_CONFIG); // pointeur register Configuration(Read/Write) i2c_write(config); // configuration i2c_stop(); // stop } //------------------------------------------------------------------------------ // Fonction lire température void read_temp() { i2c_start(); i2c_write(ADDRESS_LM92_WRITE ); // adresse du LM92 en écriture i2c_write(SET_POINTER_REGISTER_TEMP); // pointeur register Temperature (Read only) i2c_start(); // repeat-start i2c_write(ADDRESS_LM92_READ); // adresse du LM92 en lecture temp_msb = i2c_read(1); // stockage du msb temperature +ACK temp_lsb = i2c_read(0); // stockage du Lsb sans ACK i2c_stop(); // stop } void lm92_read_manufacturer_ID() { i2c_start(); i2c_write(ADDRESS_LM92_WRITE); i2c_write(lm92_manufacturer_id); i2c_start(); i2c_write(ADDRESS_LM92_READ); Manufacturer_ID_msb = i2c_read(1); // ack Manufacturer_ID_lsb = i2c_read(0); // no ack i2c_stop(); } //--------------------------------------------------------------------- // Programme principal //--------------------------------------------------------------------- void main() { setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128|RTCC_8_bit); //32.7 ms overflow setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard //Internal Oscillator Frequency Select bit 6-4 -> 111 => 8MHz bit_set(OSCCON,4); bit_set(OSCCON,5); bit_set(OSCCON,6); delay_ms(100); write_in_configuration_register(CONFIGURATION_STD); //appel à la fonction en fonction de CONFIGURATION_STD while(TRUE) { read_temp(); delay_ms(1200); } }
-----