failed to read DS1302 using pic 18f4550

Status
Not open for further replies.

ahmed osama

Full Member level 6
Joined
Jul 18, 2004
Messages
352
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Location
Cairo, Egypt, Egypt
Activity points
2,652
i succeed to set time/date @ DS1302 but i failed to read time/date

Read1302( ) return noting ... zero !!!

i tried many things

any tips ???

Code:
unsigned char DS1302OutputByte(void) 	
{ 
    
    

    unsigned char i;
    unsigned char ACC =0;

      DS1302_IO_DIR =1;  //input

      // DS1302_CLK =0;
   
    for(i=0; i<8; i++)
    {
        ACC = ACC >>1;

        ACC = DS1302_IO;
  
        DS1302_CLK = 1;
        
        DS1302_CLK = 0;
    }
     
    return(ACC); 
}




Code:
unsigned char Read1302(unsigned char ucAddr)	
{
    unsigned char ucData;
    DS1302_RST = 0;
    DS1302_CLK = 0;
    DS1302_RST = 1;
    
    DS1302InputByte(ucAddr|0x01); //this i guess that it is working
 
    
    ucData = DS1302OutputByte();
    
    DS1302_CLK = 0;
    DS1302_RST = 0;
    
    return(ucData);
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…