Author Topic: i2c debug  (Read 10954 times)

0 Members and 1 Guest are viewing this topic.

Offline WawavounTopic starter

  • Regular Contributor
  • *
  • Posts: 81
  • Country: fr
  • Someday I'll get you, Red Baron !
i2c debug
« on: February 23, 2024, 05:05:26 pm »
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 transmission ???

Thanks and regards.
Philippe

Edit 1 : I should mention that I have no battery into the module during the test.
« Last Edit: February 23, 2024, 07:21:28 pm by Wawavoun »
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
Re: i2c debug
« Reply #1 on: February 23, 2024, 10:29:32 pm »
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?
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14893
  • Country: fr
Re: i2c debug
« Reply #2 on: February 23, 2024, 10:36:45 pm »
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?
 

Offline WawavounTopic starter

  • Regular Contributor
  • *
  • Posts: 81
  • Country: fr
  • Someday I'll get you, Red Baron !
Re: i2c debug
« Reply #3 on: February 24, 2024, 07:45:06 am »
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
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14893
  • Country: fr
Re: i2c debug
« Reply #4 on: February 24, 2024, 08:21:04 am »
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?
 

Offline WawavounTopic starter

  • Regular Contributor
  • *
  • Posts: 81
  • Country: fr
  • Someday I'll get you, Red Baron !
Re: i2c debug
« Reply #5 on: February 24, 2024, 08:50:49 am »
Voltages look good as far I can see...

I will re do the test with a know working module.
 

Online Peabody

  • Super Contributor
  • ***
  • Posts: 2084
  • Country: us
Re: i2c debug
« Reply #6 on: February 24, 2024, 03:54:20 pm »
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.
 

Offline WawavounTopic starter

  • Regular Contributor
  • *
  • Posts: 81
  • Country: fr
  • Someday I'll get you, Red Baron !
Re: i2c debug
« Reply #7 on: February 25, 2024, 09:25:32 am »
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 k \$\Omega\$ on output...
This look very low comparing to the i2c sda and scl pullups (usually 4.7 k \$\Omega\$).

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
« Last Edit: February 25, 2024, 10:08:03 am by Wawavoun »
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
Re: i2c debug
« Reply #8 on: February 25, 2024, 10:59:57 am »
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?
 

Offline WawavounTopic starter

  • Regular Contributor
  • *
  • Posts: 81
  • Country: fr
  • Someday I'll get you, Red Baron !
Re: i2c debug
« Reply #9 on: February 25, 2024, 01:34:04 pm »
Solved !

PB0 and PB1 inverted in the software... |O

Thanks to all for the help.
Philippe
 
The following users thanked this post: newbrain, SiliconWizard

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
Re: i2c debug
« Reply #10 on: February 25, 2024, 09:18:55 pm »
Wonderful and congrats, thanks for letting us know. :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf