Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Where can I find out how to do the bit level manipulation so I can read the data from my i2c device DS1307 real time clock. My programming experience is limited to VBA and the like. Attached is the DS1307 datasheet and I would like to know where to start with the mbed i2c library.Which reads and writes should I do and in what order ? /media/uploads/GregMartin/ds1307.pdf
#include "mbed.h" I2C i2c(p9, p10); // sda, scl Serial pc(USBTX, USBRX); // tx, rx const int addr = 0x68; // define the I2C Address int main() { char cmd[10]; cmd[0] = 0x0; // pointer to command register cmd[1] = 0xd1; //read address. I dont know if these is are correct addresses cmd[2]=0xd0 ; //write address cmd[3]=0x03f; //some address i2c.write(addr, cmd, 2); // Send command string i2c.read(addr,cmd,3); pc.printf("cmd[2]= %x\n",cmd[2]); pc.printf("Mystring= %x\n",cmd[3]); }