Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/24/07 04:42
Read: times


 
#142232 - RTC ds1307 with AT89C51
hi all,

this is my code for rtc. can anyone tell me what's wrong in this?
I beleive read and write operations are not working.




typedef unsiged char byte;


// master transmit-slave receive mode

void write(byte dataa)
{
byte i;
for(i=0; i<8; i++) //8-bit data format...
{
scl=0;
//to ensure that change on sda line is unnoticed.
_nop_();
sda= ( dataa & (0x80 >> i) ) ? 1:0; //MSB. First
_nop_();
scl=1;
_nop_();
}
}



//master receive slave transmit mode.

byte read(void)
{
byte dataa,i;
scl=0;
for(i=0,dataa=0;i<8;i++)
{
scl=0;
_nop_();
scl=1;
dataa= (sda)?( (dataa <<1) | 1 ):((dataa <<1));
_nop_();

}
return dataa;
}

sarma.C.S.M.G

List of 3 messages in thread
TopicAuthorDate
RTC ds1307 with AT89C51            01/01/70 00:00      
   For a start            01/01/70 00:00      
   here are 2 procedures, not code for RTC            01/01/70 00:00      

Back to Subject List