Shop OBEX P1 Docs P2 Docs Learn Events
SX52 with LM92 thermal Sensor - Master ACK - Alternative Methods? — Parallax Forums

SX52 with LM92 thermal Sensor - Master ACK - Alternative Methods?

I have about two weeks under my belt playing with micro controllers at assembly level. So I figure I am missing something obvious here that some old dogs already know.

The attached code works great except it will not capture the first bit of the second byte if that bit is HI. I have tried different timings and different LM92 Chips. The LM92 requires an ACK from the master before it will send the second byte. So the only thing I can think is that I am not applying the ACK as effectively as I could. Especially, as I see a small pulse high just before the ACK clock pulse. All the LM92 chips work report correctly with an Arduino and I do not see the weird pulse.


Comments

  • ZootZoot Posts: 2,227
    A few things I see, though these may not be the problem. First, you really should "release" SDA/SCL to inputs to let them go high, rather than driving them high. This is the I2C spec -- pullups on SDA/SCL, they are only driven low.

    Second, you may try this, to ensure that SDA doesn't glitch high on your ACK:
            clrb	rc.0
    	mov	!rc, #$00		;master must issue an ACK for the LM92 to process further output so set the SDA to output mode
    	clrb	rc.0			;hold the SDA line low during the ACK clock pulse
    	call	@scl_pulse		;ACK clock pulse after byte transfer
    	setb	rc.0			;release the SDA line
    	mov	!rc, #$01		;SDA control back to the LM92 output
    	call 	@timer_10us		;just for spacing so easier to see on o-scope
    

    Lastly, and this I can't speak to based on your Arduino tests, your assembly I2C routines don't account for clock stretching. Suppose it's possible your slave device is clock stretching before the second byte (but seems less likely given the behavior you report).

    You could also try using SX/B which contains really solid ready-to-go I2C routines.
Sign In or Register to comment.