Problem LV2433A and DS1307

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
amiracherazed
Posts: 3
Joined: 17 Apr 2011 10:23

Problem LV2433A and DS1307

#1 Post by amiracherazed » 17 May 2011 11:31

hi every body ,i'm using the LV2433A developing board every thing was working till i tryed to programme the DS1307 real clock ,,the program is working fine with simulation in pproteus ,but in the reality i can't get eny respons from the DS1307 ,i dont know if the problem is hard or soft here is the code i used .

Code: Select all

char time=0x44;
unsigned temp;
unsigned x=0x44;
unsigned i=0;
void main(){
uart1_init(9600);
I2C1_Init(100000);
//µµµµµµµµµµµµµµµµµµµµµ
 I2C1_Start();
  I2C1_Write(0xD0);
  I2C1_Write(0x00);
  I2C1_Write(0x00);
  I2C1_Write(0x59);
  I2C1_Write(0x23);
  I2C1_Write(0x2);
  I2C1_Write(0x25);
  I2C1_Write(0x11);
  I2C1_Write(0x11);
  I2c1_Stop();
 //µµµµµµµµµµµµµµµµµµµµµ
     while(1){
       I2C1_Start();
       I2C1_Write(0xD0);
  I2C1_Write(0x00)  ;
   //µµµµµµµµµµµµµµµµµµµ
   I2C1_Restart();
  I2C1_Write(0xD1);
  x = I2C1_Read(0); //Seconds
    time = x & 0x30; //Avoid the CH bit
    time >>= 4;
    time += '0';
    uart1_write_char(time);
    time = x & 0x0F;
    time += '0';
    uart1_write_char(time);

    //=======================

    //=======================
I2C1_Wait_For_Idle();

    x = I2C1_Read(0); //Minutes
    temp = x & 0xF0 ;
    temp >>= 4;
    temp += '0';
	time=temp;
	uart1_write_char(time);
	delay_ms(100);
    temp = x & 0x0F;
    temp += '0';
	time=temp;
	uart1_write_char(time);
	
    //=======================
    //=======================
I2C1_Wait_For_Idle();
    x = I2C1_Read(1);//Read hours register
    temp = x & 0xF0 ;
    temp >>= 4;
    temp +='0';
    time=temp;
	uart1_write_char(time);
    temp = x & 0x0F;
    temp += '0';
    time=temp;
	uart1_write_char(time);
     I2c1_Stop();
     uart1_write_char(' ');
}

     }

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: Problem LV2433A and DS1307

#2 Post by slavisa.zlatanovic » 18 May 2011 13:22

Hi!

Did you place the pull-up resistors at SCL and SDA lines?
Best regards
Slavisa

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”