Monday, March 8, 2010


Finally I got it working yesterday! The problem with TWI was not in MCU nor in software TWI Master implementation, but in differences in addressing.

In LM75A datasheet said that 7-bit addressing used for the device. MSB bits are always set to 1001, and value of 3 lower bits depends on logic level on pins A0:A2. As A0:A2 pins I have connected to Vcc, address of my sensor is b01001111 (8-bit binary) = 0x4F (hexadecimal). I have successfully used this address with Arduino and all was working as expected.

But when I started with ATTiny13 running software TWI nothing were working. As I haven’t full-functional digital oscilloscope, I had tried to make some “poor man’s logic analyzer” using codes from here. Got it working, but results were strange to me because SCL signal on TWI bus wasn’t like a strobe but more likely signal. So I decided to make more research over the net.

Fortunately I have found topic on forum where somebody discussed interaction with different LMxx sensor, and I noticed strange addressing in code. Address of device were 0x90 that corresponds to b10010000. I have maid guess that address should be not left-padded as I used it with Arduino, but right-padded. I put b10011110 (0x9E hex comparing to 0x4F I've used before) as address and now everything is working just fine!

No comments:

Post a Comment