i2c debug - Page 1
Forum section: electronics / projects

author: Wawavoun
author_rank: Regular Contributor
timestamp: February 23, 2024, 05:05:26 pm
content: Hello All,I try to talk i2c to a DS3231 module and first I try to read the temperature. I do that with a 6809 proc via a 6522 B port bit 0 and 1.The DS3231 reply with a great constancy $FF for temperature MSB and LSB.The recording of the i2c session is here.The point looking strange is that the DS3231 reply NACK to device selection, to data write instruction and to address to read... Reading the datasheet this should be a ACK.Can somebody point to me what is wrong in the transmissionThanks and regards.PhilippeEdit 1 : I should mention that I have no battery into the module during the test.

author: moffy
author_rank: Super Contributor
timestamp: February 23, 2024, 10:29:32 pm
content: Not sure that the 6522 is level compatible with I2C, which typically has pull up resistors of around 1.5k. Maybe you would be better off inserting a TTL to I2C buffer between the 6522 and the I2C?

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 23, 2024, 10:36:45 pm
content: The line just seems stuck to 1 when the slave should reply, which is what you should have concluded here IMO and which makes sense as I don't think a 6522 can be configured with open drain outputs. (Or if it can let me know.)So let us know a bit more about how that's configured. How do you use the 6522 to emulate I2C?

author: Wawavoun
author_rank: Regular Contributor
timestamp: February 24, 2024, 07:45:06 am
content: I use the 6522 as follow.For writing (master --> slave) :First I set the output register definitively to $00.Then I use only the data direction register.To get logic high I configure the line as an input so, thanks to the pull up resistors (4.7 k), the line go to logic high.To get a logic low I set the pin as an output and, thanks to output register set to 0, the line go to logic low.For reading (slave --> master) :The 6522 pin is set as input and the ds3231 module (open drain outputs) do the job.For information SCL frequency during data transmission is around 38 KHz.At least the logic analyzer see zero and one. But to get the real voltage level I have to check with a scope.Thanks for the help.Regards.Philippe

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 24, 2024, 08:21:04 am
content: Ok then, your method looks correct. Should work. The slave address you use looks also correct. So, I don't know. 3 things to check: 1/ to make sure the direction of the SDA line is effectively set to input on the 6522 when reading the ACK bits and for the read bytes, 2/ to indeed look at SDA with a scope, to see if the signal drops when it should be read as 0, but not enough to pass the low threshold. That may be the case here. Finally, 3/ make sure the DS3231 you use is actually working - do you have any MCU dev board or a I2C-USB bridge you could test it with?

author: Wawavoun
author_rank: Regular Contributor
timestamp: February 24, 2024, 08:50:49 am
content: Voltages look good as far I can see...I will re do the test with a know working module.

author: Peabody
author_rank: Super Contributor
timestamp: February 24, 2024, 03:54:20 pm
content: The 32KHz output pin is active on powerup, so if the oscillator is running, you should see that on your scope. But it is open drain, so will need a pullup resistor.

author: Wawavoun
author_rank: Regular Contributor
timestamp: February 25, 2024, 09:25:32 am
content: Tested on another computer the module is ok.The 32 KHz clock is running.The scope dont show any voltage drop on SDA when ACK should take place. But I should verify again this point.Further to some searches it appears that 6522 VIA has pullups resistors around 1 kon output...This look very low comparing to the i2c sda and scl pullups (usually 4.7 k).I dont find in DS3231 datasheet if the sda output is capable to set this to logic 0 (need ~5.7 mA for 0.3 V level on the line)Any advice about this ?Regards.Philippe

author: moffy
author_rank: Super Contributor
timestamp: February 25, 2024, 10:59:57 am
content: Even if the DS3231 couldn't handle the full load (it probably can) you would expect to see some level of pull down but the scope shows nothing. Have you tried a reset immediately before the bus query?

author: Wawavoun
author_rank: Regular Contributor
timestamp: February 25, 2024, 01:34:04 pm
content: Solved !PB0 and PB1 inverted in the software...Thanks to all for the help.Philippe

author: moffy
author_rank: Super Contributor
timestamp: February 25, 2024, 09:18:55 pm
content: Wonderful and congrats, thanks for letting us know.