start signal (clock line is high, data line is changed from high to low): void AT24C04_Start(){SDA = 1; //pull high data line SCL = 1; Clock line Delay5us (); //delay SDA = 0; //generate a falling edge Delay5us (); //delay SCL = 0; //pull down the clock line } end signal: (clock line is high, the data line is Low to high) void AT24C04_Stop(){SDA = 0; //Pull low data line SCL = 1; //Pull high clock line Delay5us(); //Delay SDA = 1; //Generate rising edge Delay5us(); //delay}byte transfer: (8 bits per byte, one byte with a corresponding bit) Send data: void AT24C04_SendByte(BYTE dat){BYTE i;for (i=0; i<8; i++ //8-bit counter {dat <<= 1; //remove the highest bit of data SDA = CY; //send data port SCL = 1; //pull clock line Delay5us(); //delay SCL = 0; //Pull down the clock line Delay5us(); //delay}AT24C04_RecvACK();}Receive data: BYTE AT24C04_RecvByte(){BYTE i;BYTE dat = 0;SDA = 1; //Enable internal pull-up Ready to read data for (i=0; i<8; i++) //8-bit counter {dat <<= 1;SCL = 1; //pull the clock line Delay5u s(); //delay dat |
= SDA; //read data SCL = 0; //pull down the clock line Delay5us (); //delay } return dat; } data response: each time the data transmission is successful, the receiving device sends a response signal, when the ninth The signal generation is that the device that generates the acknowledgment signal pulls SDA low. After receiving the start condition and the slave address, answer and select the read/write operation. For a write operation, each time a byte is received, 24c02 sends an acknowledgement signal. The read operation, after a byte is sent, releases the bus and waits for a reply signal. Receiving the response signal continues to transmit data, receives a non-acknowledgement signal, and waits for the reception end signal. Send the response signal when reading data void AT24C04_SendACK (bit ack) {SDA = ack; //write response signal SCL = 1; //pull up the clock line Delay5us (); //delay SCL = 0; //pull down the clock line Delay5us(); //delay} Receive response signal bit AT24C04_RecvACK(){SCL = 1; //High clock line Delay5us(); //Delay CY = SDA; //Read response signal SCL = 0 //Pull down the clock line Delay5us(); //Delay return CY;}Page write and read program: void AT24C04_WritePage(){BYTE i;AT24C04_Start(); //Start signal AT24C04_SendByte(0xa0); //Send device address + write signal AT24C04_SendByte (0x00); //Send memory location address for (i=0; i<16; i++){AT24C04_SendByte(TESTDATA[i]);}AT24C04_Stop(); //stop signal}
The following error message appears after starting vnc4server: LSPPC-Lenny:~# vnc4serverxauth: (stdi
According to statcounter statistics, the global operating system market share in March is still Win7
1. Install Oracle VM virtualBox, I am using version 4.0. The official download address is here. 2.
At present, many schools have built campus networks and connected to the Internet, but there are so
Linux ends with a keyword process (batch kill process method)
More effective management Five cool Linux command line tricks
Solve ntp error no server suitable for synchronization found
IIS server does not support ASP.NET solution
Linux kernel preemption implementation mechanism analysis
Analysis of the main points of Linux system cluster technology
Linux adsl dialing and sharing Internet
Ultra-simple Centos vpn build method only needs three, quickly build vpn
Linux Server Network Development Model
Connect the USB flash drive to the VMware virtual machine Tutorial
Which keyboard Win key is the Windows key?
Windows 7 install font shortcuts
How to remove the boot interface Win10 system option
Windows 8.1 how to solve the pop-up automatic dialing window
How does Win10 make teamviewer boot up?
IE11 can not open the local website under Win8.1
Improve the speed of five strokes practice
Let Win7 sleep recovery when constantly online
How to solve the application error28000 when installing the U disk?