Gast
#53631
Hallo Alle, ich habe hier ein seeehr ernstes Problem mit einer C-Control, mit der ich einen LM75 über I2C auslesen will. Das Problem ist, dass ich zwar Werte empfange, diese aber immer nur in 2°-Schritten an- und absteigen. Ich kann das einfach nicht nachvollziehen, zumal der Quelltext OK zu sein scheint. Here it goes: scl = 1 'I2C im Ruhezustand sda = 1 pause t sda = 0 : pause t 'Start Condition scl = 0 : pause t sda = 1 : tog scl : tog scl 'Geräteadresse senden sda = 0 : tog scl : tog scl sda = 0 : tog scl : tog scl sda = 1 : tog scl : tog scl sda = 0 : tog scl : tog scl sda = 0 : tog scl : tog scl sda = 0 : tog scl : tog scl sda = 1 scl = 1 'Lesemodus pause t scl = 0 DEACT sda ' MSB vom I2C Bus lesen msb = 0 for i=0 to 7 scl = 1 : pause t if sda then msb = msb or &B00000001 if sda = 0 then msb = msb and &B11111110 msb = msb shl 1 scl = 0 : pause t next sda = 0 scl = 1 : pause t scl = 0 DEACT sda pause t ' LSB vom I2C Bus lesen lsb = 0 for i=0 to 7 scl = 1 : pause t if sda then lsb = lsb or &B00000001 if sda = 0 then lsb = lsb and &B11111110 lsb = lsb shl 1 scl = 0 : pause t next DEACT sda tog scl : tog scl sda = 0 scl = 1 : pause t sda = 1 print msb; return "Print msb" gibt immer nur Werte in Zweierschritten aus, also 20, 22, 24 etc. Hat jemand eine Ahnung, woher das kommt? Gruß, Christoph