Electronics > Projects, Designs, and Technical Stuff
Confused about how this I2C read works
<< < (5/8) > >>
Chet T16:
I done some more testing, after a write the slave will pull the third line low waiting for a read. If it doesn't get one it will release the line and try twice more. If i initiate a read when its pulled low i can read the data, either the 2 or 5 bytes depending on whether the buttons are pressed. Strangely although reading them fine the arduino is is not sending an ACK for the last byte which causes the slave to try to send everything again (twice more, as above) so if i read a button press i will actually see it three times.


--- Quote from: amyk on March 02, 2013, 07:15:59 am ---
--- Quote from: Chet T16 on February 25, 2013, 04:23:26 pm ---Inside the slave is some Sagem ic (AFRHEUT0200 HD6433834822H) that isn't throwing up any results on google and a few other bits - voltage reg, inverter, discretes etc

--- End quote ---
I think you misread the part# as that is probably the HD6433834S - Hitachi (now Renesas) H8 microcontroller. The datasheet does not explicitly mention CAN or I2C but there is a UART peripheral capable of different transfer modes. Or they could be bit-banging I2C/CAN...

--- End quote ---

I didn't take the display apart again (it has one of thos super thin ribbon cable things attaching the LCD that i don't want to break) but the package seems to match up. Good spot!
Chet T16:
Some logic analyser screen grabs

Here is a read with the original master and slave



And here is one with me as master

amyk:
Since this might not really be I2C you may be violating some timing requirement.
richcj10:
Some devices don't care or want to see the NAK.
Other IC's really care about seeing the ACK. 
Try that first.
TerminalJack505:
The Arduino library will send a NACK when it has received the last byte.  This is normal.  It's supposed to tell the slave that the master is done reading. 

You might be able to emulate the behavior you are seeing by calling Wire.requestFrom() with a quantity parameter value that is larger than the number of bytes you actually expect.

If that doesn't work AND you actually need that behavior then you might just try bit-banging the I2C bus yourself.

The attached ZIP has the code from a simple little project I did with an ATtiny2313, which has no native I2C support.  I'm pretty sure the code for bit-banging the I2C bus was taken pretty much as-is from an Atmel app note.  I likely just wrapped their code in a C++ class.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod