Je n'arrive pas a synchroniser mon pic avec une rtc DS1307
L'écran affiche le message ci dessous même si on change les paramètres d'initialisation de sec,min, ....
Date:08.04.2010.
Time:23:23:13
Est ce que quelqu'un peut m' aiguiller pour résoudre mon pb ?
Merci.
/************************* bit definitions *************************/
// Software I2C connections
sbit scl at RC3_bit;
sbit sda at RC4_bit;
//sbit sqw at ?????;
sbit scl_Direction at TRISC3_bit;
sbit sda_Direction at TRISC4_bit;
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned char I2C_write(unsigned char d )
{
unsigned char i, AckMissing;
scl = 0; delay_us(8); /* tLOW=4.7µs mini */
for (i = 1; i <= 8; i++)
{
sda = (d >> 7); delay_us(1); /* SU:DAT=0.25µs mini */
scl = 1; delay_us(8); /* tHIGH=4µs mini */
d = d << 1; /* increase scl high time */
scl = 0; //delay_us(8); /* tLOW=4.7µs mini */
}
Sda_Direction=1; // 1 : Entrée
AckMissing=sda; // Récup d'un 0 sur sda si OK //
sda_Direction=0; // 0 : Sortie
Lcd_Out(1,1,"Date:"); // Prepare and output static text on LCD
Lcd_Chr(1,8,'.');
Lcd_Chr(1,11,'.');
Lcd_Chr(1,16,'.');
Lcd_Out(2,1,"Time:");
Lcd_Chr(2,8,':');
Lcd_Chr(2,11,':');
Lcd_Out(1,12,"201"); // start from year 2010
I2C_start(); /* The following Enables the Oscillator */
I2C_write(0xd0); /* address the part to write */
I2C_write(0x00); /* position the address pointer to 0 */
I2C_write(0x00); /* write 0 to the seconds register, clear the CH bit */
I2C_stop();