Download LED Display by 8051 PDF

TitleLED Display by 8051
Tags Light Emitting Diode Electronic Circuits Prototype Real Time Computing
File Size1.7 MB
Total Pages56
Document Text Contents
Page 29

ENG499 CAPSTONE PROJECT REPORT 28

//-------------------------------

// start I2C

//-------------------------------

void Start(void)

{

SDA = 1;

SCL = 1;

_nop_();_nop_();

SDA = 0;

_nop_();_nop_();

SCL = 0;

_nop_();_nop_();

}

//-------------------------------

// stop I2C

//-------------------------------

void Stop(void)

{

SDA = 0;

_nop_();_nop_();

SCL = 1;

_nop_();_nop_();

SDA = 1;

}

During the period of data transfer, the AT89S52 will read the real time clock

information or write data for the adjustment of time when necessary.

//-------------------------------

// Read RTC (all real time)

//-------------------------------

void ReadRTC(unsigned char * buff)

{

Start();

WriteI2C(0xD0);

WriteI2C(0x00);

Start();

WriteI2C(0xD1);

*(buff+0)=ReadI2C(ACK); // Second

*(buff+1)=ReadI2C(ACK); // Minute

*(buff+2)=ReadI2C(ACK); // hour

*(buff+3)=ReadI2C(ACK); // Day

*(buff+4)=ReadI2C(ACK); // date

*(buff+5)=ReadI2C(ACK); // month

*(buff+6)=ReadI2C(NO_ACK); // year

Stop();

}

//-------------------------------

// Write RTC

//-------------------------------

void WriteRTC(unsigned char *buff)

{

Similer Documents