AT24C256 multi-page read/write key program segment

Source: Internet
Author: User

After a full page is written, you need to end the bus, restart the bus, write SLA, write Suba on the next page, and write data ....

A delay must be added between the end bus and the start bus. It takes a long time !!

Extern unsigned char enumer; bit isendstr (unsigned char SLA, unsigned int Suba, unsigned char * s, unsigned char no) {unsigned char I; unsigned int K; // start_i2c (); /* Start bus */sendbyte (SLA);/* Send device address */If (ACK = 0) Return (0 ); //////////////////////////////////////// /// if (AT24C256 = AT24C256) {sendbyte (unsigned char) (Suba> 8); // convert integer data to bytes-type data: discard height to low, take only eight digits below.
// If the capacity is greater than 32 K bits, use 16-bit address addressing, write the high eight-bit address if (ACK = 0) Return (0);} sendbyte (unsigned char) suba);/* Send device sub-address */If (ACK = 0) Return (0); for (I = 0; I <no; I ++) **************** * ******** // If (Suba % 64 = 0) {stop_i2c (); For (k = 0; k <10000; k ++); start_i2c ();/* Start bus */sendbyte (SLA ); /* Send device address */If (ACK = 0) Return (0); // If (AT24C256 = AT24C256) {sendbyte (unsigned char) (Suba> 8); // converts integer data to bytes-type data: discard the height to a lower value, and only take the lower 8 bits.
// If the capacity is greater than 32 K bits, use 16-bit address addressing, write the high eight-bit address if (ACK = 0) Return (0);} sendbyte (unsigned char) suba);/* Send device sub-address */If (ACK = 0) Return (0);} Suba ++; *************** * ************ // * send data */sendbyte (* s ++ ); if (ACK = 1) continue; // return (0 ); /// // senddd ('x '); // This Is Not found. · // return (0); //} stop_i2c ();/* End bus */Return (1 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.