24c02读写c语言程序(24C02 read and write C language program)
24c02读写c语言程序(24C02 read and write C language program)
24C02 read and write C language program - here is the source code I prepared
2010-09-01 10:08
> below is the source code I have written, has been successfully debugged, you can use the download, the program is not very standardized
I hope you can criticize me!!!
>/***********************************************************
>** module name: 24C02 read and write
>** written: Bradley date 200551
>** modifier: Bradley
>** Function Description: 8 bytes of data into 24C02, and then read out the delivery port P1 display
>** other Description: This program is continuously read and write 8 bytes of data written by the 24C02 page
>** version: keil 7
>**********************************************************/
>#include
>#include
>//#define uchar unsigned char
>#define uint unsigned int
>#define WC24C02 0x0a0; / / device address
>#define R24C02 0x00; / / write data.
>#define W24C02 0x00; / / read data.
>sbit SDA=P3^7; / / define data line
>sbit SCL=P3^6; / / define the clock line
>bit flag;
>uint IData ucSendBuffer[8]={0x01,0x02,0x04,0x08,
> 0x10,0x20,0x40,0x80};
>uint IData ucReceData;
>uint IData ucReceiveBuffer[8]; / / multi byte data buffer is read from the device
>void, delay ();
>void, delay_10ms ();
>void, ACK ();
>void, NoACK ();
>/*********************************************************
>** Name: I2C_Start
>** function: start I2C
>** input: no
>** returns: no
>*********************************************************/
>void, I2C_Start ()
>{
> SDA=1;
> delay ();
> SCL=1;
> delay ();
> SDA=0;
> delay ();
> SCL=0; / / clamp I2C bus, ready to send data
>}
>/**********************************************************
>** Name: I2C_Stop
>** function: stop I2C
>** input: no
>** returns: no
>**********************************************************/
>void, I2C_Stop ()
>{
> SDA=0;
> delay ();
> SCL=1;
> delay ();
> SDA=1;
> delay ();
>}
>/**********************************************************
>**