Hi,
the last release of the Wire library has added support for an extra parameter to the Wire.endTransmission and Wire.requestFrom, to specify if a STOP should be sent or not. Nevertheless, it seems it is not working for Due. I have inspected the source code for the two aforementioned methods and they ignore the boolean parameter altogether. I have also inspected the SCL and SDA lines with an oscilloscope and I could clearly see the STOP condition being sent.
Am I missing something? or is this not supported on Due yet?
Hello,
what board are you going to use ? What are the specific I2C transactions that you'll need?
With the Due board, I was able to read/write from/to an internal register of a I2C slave device (MLX90614), using the API in the libsam library. You can find the source in
arduino-1.5.1r2\hardware\arduino\sam\system\libsam\source. Look for twi.c and twi.h
The functions of interest are void TWI_StartRead and void TWI_StartWrite. They both have a parameter called uint32_t iaddress where you can put the internal address/register you want to access. If you specify it, then the controller will automatically send a REPEATED START condition after writing the address of the slave device and of the internal register on the bus and before reading/writing the data bytes.
Best regards,
Dan.
chriskner:
Dan,
I'm about to start an I2C project that may require I2C repeated starts.
There's a bit of history with these boards (struggling to get other external uC's to issue an I2C repeated start without stop), so your post caught my attention.
I appreciate the pointers, and any other suggestions you may have.
I also have confirmed that a 'Stop' is always sent regardless of including true/false in endTransmission().
I can supply logic traces if anyone's interested.
Now, perhaps this neophyte could have a bit more help?
How does one invoke 'TWI_Startread' in code? Specifically, what would I include for the first parameter: TWI_StartRead(???, i2c_addr, i2c_register, 8 );
The first param is a pointer to a Twi structure denoting the I2C bus that you want to use.
In the case of arduino due there are 2 I2C buses, therefore you can use WIRE_INTERFACE_ID or WIRE1_INTERFACE_ID. Both of them are defined in hardware\arduino\sam\variants\arduino_due_x\variant.h
After some turmoil, I have retreated to the state where only 1 byte at a time may be read from a slave.
Figure 34-20. "TWI Read Operation with Multiple Data Bytes with or without Internal Address" in the SAM3X8E datasheet seems out of reach. (Page 729, of the 28-May-12 revision)
I have found that a NACK is always generated after the 1st read by some unidentified mechanism, making multiple byte reads impossible.
For the desired protocol, see Figure 34-10. "Master Read with Multiple Data Bytes" (Page 721).
Hello,
I use this code to read the temperature from the MLX90614 IR sensor (see attachment).
The sensore has address 0x5A and I read 3 bytes from internal address 0x07.
As you can see in the captured signal, the controller sends 2 ACK and one NACK just before the STOP condition.
I suppose there is something wrong in your code, can you send it to me to have a look? Or share it somewhere on the internet.
Do you mind sharing the code for the use of a MLX90614? I'm also trying to get one running on a Due, but unfortunatelly I'm really not into (machine)code. What I've seen in your posts is really to much for me.