hola flico, gracias por tu interes en ayudarme. Mira el codigo que utilizo es este, tanto para leer la hora como para establecerla:
//
// Maurice Ribble
// 4-17-2008
// http://www.glacialwanderer.com/hobbyrobotics
// This code tests the DS1307 Real Time clock on the Arduino board.
// The ds1307 works in binary coded decimal or BCD. You can look up
// bcd in google if you aren't familior with it. There can output
// a square wave, but I don't expose that in this code. See the
// ds1307 for it's full capabilities.
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
// Stops the DS1307, but it has the side effect of setting seconds to 0
// Probably only want to use this for testing
/*void stopDs1307()
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(0x80);
Wire.endTransmission();
}*/
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour)); // If you want 12 hour am/pm you need to set
// bit 6 (also need to change readDateDs1307)
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
// Change these values to what you want to set your clock to.
// You probably only want to set your clock once and then remove
// the setDateDs1307 call.
second = 30;
minute = 55;
hour = 13;
dayOfWeek = 6;
dayOfMonth = 19;
month = 3;
year = 11;
//DESCOMENTAR ESTA LINEA PARA PONER EN HORA....................................................................
// setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.print(second, DEC);
Serial.print(" ");
Serial.print(dayOfMonth, DEC);
Serial.print("/");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(year, DEC);
Serial.print(" Day_of_week:");
Serial.println(dayOfWeek, DEC);
delay(1000);
}
Si quito 1 de las pantallas LCD y dejo solo una conectada, obtengo el mismo problema:
20:14:35 6/4/11 Day_of_week:3
20:14:36 165/165/165 Day_of_week:7
0:0:0 0/0/0 Day_of_week:0
20:14:38 6/4/11 Day_of_week:3
20:14:39 165/165/165 Day_of_week:7
20:14:40 6/4/11 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:14:42 6/4/11 Day_of_week:3
20:14:43 6/4/11 Day_of_week:3
20:14:44 6/4/11 Day_of_week:3
20:14:45 6/4/11 Day_of_week:3
0:0:3 2/0/20 Day_of_week:0
20:14:47 6/4/11 Day_of_week:3
20:14:48 6/4/11 Day_of_week:3
20:14:49 6/4/11 Day_of_week:3
20:14:50 6/4/11 Day_of_week:3
20:14:51 6/4/11 Day_of_week:3
20:14:52 6/4/11 Day_of_week:3
0:0:53 0/0/0 Day_of_week:0
20:14:54 6/4/11 Day_of_week:3
20:14:55 6/4/11 Day_of_week:3
20:14:56 6/4/11 Day_of_week:3
20:14:57 6/4/11 Day_of_week:3
0:0:59 0/0/0 Day_of_week:0
20:15:0 6/4/11 Day_of_week:3
20:15:1 6/4/11 Day_of_week:3
20:15:2 6/4/11 Day_of_week:3
20:15:3 6/4/11 Day_of_week:3
20:15:4 6/4/11 Day_of_week:3
20:15:5 6/4/11 Day_of_week:3
20:15:6 6/4/11 Day_of_week:3
20:15:7 6/4/11 Day_of_week:3
20:15:8 6/4/11 Day_of_week:3
20:15:9 6/4/11 Day_of_week:3
20:15:10 6/4/11 Day_of_week:3
20:15:11 6/9/165 Day_of_week:3
20:15:12 6/4/11 Day_of_week:3
1:15:13 165/165/165 Day_of_week:165
20:15:14 6/4/11 Day_of_week:3
20:15:15 6/4/11 Day_of_week:3
20:15:16 6/4/11 Day_of_week:3
20:15:17 6/4/11 Day_of_week:3
20:15:18 6/4/11 Day_of_week:3
20:15:19 6/4/11 Day_of_week:3
20:15:20 6/9/165 Day_of_week:3
20:15:21 6/4/11 Day_of_week:3
20:15:22 6/4/11 Day_of_week:3
20:15:23 6/4/11 Day_of_week:3
20:15:24 6/4/11 Day_of_week:3
0:0:3 2/0/20 Day_of_week:0
20:15:26 6/4/11 Day_of_week:3
por lo que no creo que sea problema de la doble dirección lcd ya que ahora no estan conectadas las 2, solo 1.
si dejo solo conectado el RTC...
20:16:28 6/4/11 Day_of_week:3
20:16:29 6/4/11 Day_of_week:3
20:16:30 6/4/11 Day_of_week:3
20:16:31 6/4/11 Day_of_week:3
20:16:32 6/4/11 Day_of_week:3
20:16:33 6/4/11 Day_of_week:3
0:0:3 2/0/20 Day_of_week:0
20:16:35 6/4/11 Day_of_week:3
20:16:36 6/4/11 Day_of_week:3
20:16:37 6/4/11 Day_of_week:3
20:16:38 6/4/11 Day_of_week:3
20:16:39 6/4/11 Day_of_week:3
20:16:41 6/4/11 Day_of_week:3
20:16:42 6/4/11 Day_of_week:3
20:16:43 6/4/11 Day_of_week:3
20:16:44 6/4/11 Day_of_week:3
20:16:45 6/4/11 Day_of_week:3
20:16:46 6/4/11 Day_of_week:3
20:16:47 6/4/11 Day_of_week:3
20:16:48 6/4/11 Day_of_week:3
20:16:49 6/4/11 Day_of_week:3
20:16:50 6/4/11 Day_of_week:3
20:16:51 6/4/11 Day_of_week:3
20:16:52 6/4/11 Day_of_week:3
20:16:53 6/4/11 Day_of_week:3
20:16:54 6/4/11 Day_of_week:3
20:16:55 6/4/11 Day_of_week:3
20:16:56 6/4/11 Day_of_week:3
20:16:57 6/4/11 Day_of_week:3
20:16:58 6/4/11 Day_of_week:3
20:16:59 6/4/11 Day_of_week:3
20:17:0 6/4/11 Day_of_week:3
20:17:1 6/4/11 Day_of_week:3
20:17:2 6/4/11 Day_of_week:3
20:17:3 6/4/11 Day_of_week:3
20:17:4 6/4/11 Day_of_week:3
20:17:5 6/4/11 Day_of_week:3
20:17:6 6/4/11 Day_of_week:3
20:17:7 6/4/11 Day_of_week:3
20:17:8 6/4/11 Day_of_week:3
20:17:9 6/4/11 Day_of_week:3
20:17:11 6/4/11 Day_of_week:3
si conecto las 2 LCDs se puede ver como la situación es mucho peor, pero que los datos si que estan correctos en el modulo RTC, solo que no los coge bien
21:30:25 165/165/165 Day_of_week:165
0:0:0 0/0/0 Day_of_week:0
20:30:27 0/0/0 Day_of_week:3
20:30:28 6/4/0 Day_of_week:3
3:0:3 165/165/165 Day_of_week:165
45:61:30 165/165/165 Day_of_week:165
45:165:31 165/165/165 Day_of_week:165
20:30:32 165/165/165 Day_of_week:7
0:0:0 0/0/0 Day_of_week:0
3:30:34 165/165/165 Day_of_week:165
20:30:35 6/4/11 Day_of_week:3
20:30:36 21/165/165 Day_of_week:3
20:30:37 6/4/11 Day_of_week:3
45:165:7 165/165/165 Day_of_week:165
20:30:39 165/165/165 Day_of_week:7
20:30:40 6/0/0 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:30:42 0/0/0 Day_of_week:3
3:11:4 1/165/165 Day_of_week:0
20:30:44 6/4/11 Day_of_week:3
20:30:45 6/4/11 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:30:48 6/9/165 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:30:50 165/165/165 Day_of_week:25
20:30:51 6/4/11 Day_of_week:3
0:0:3 2/0/20 Day_of_week:0
20:30:53 6/4/11 Day_of_week:3
20:30:54 0/0/0 Day_of_week:3
20:30:55 6/0/0 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:30:57 6/4/11 Day_of_week:3
21:30:58 165/165/165 Day_of_week:165
20:30:59 6/4/11 Day_of_week:3
0:0:0 0/0/0 Day_of_week:0
20:31:1 0/0/0 Day_of_week:0