Turn 24lc512 datasheet
24lc512 datasheet
Description : This article explains how to integrate EEPROM with a micro controller. Hardware : Micro Controller - PIC24F series, EEPROM - 24LC512, 8MHz Crystal, Communication : on same PCB, SPI is good for longer tracks/cables Software : void InitI2C2 void unsigned int config1 0; void EEPROMWriteByte unsigned long int address, BYTE data // START IdleI2C2 ; //Clear interrupt flag // Control Byte MasterWriteI2C2 0xA0 ; //Write Slave address and set master for transmission while I2C2STATbits.TBF ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // Address MSB MasterWriteI2C2 address >> 8 & 0x00ff ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // Address LSB MasterWriteI2C2 address & 0x00ff ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // data byte MasterWriteI2C2 data ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // make sure write cycle is complete by polling acknowledgement from slave do // start IdleI2C2 ; //Clear interrupt flag // Control Byte MasterWriteI2C2 0xA0 ; //Write Slave address and set master for transmission while I2C2STATbits.TBF ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; //Clear interrupt flag // Control Byte MasterWriteI2C2 0xA0 ; //Write Slave address and set master for transmission while I2C2STATbits.TBF ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // Address MSB MasterWriteI2C2 address >> 8 & 0x00ff ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // Address LSB MasterWriteI2C2 address & 0x00ff ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; //Clear interrupt flag // Control Byte MasterWriteI2C2 0xA1 ; //Write Slave address and set master for transmission while I2C2STATbits.TBF ; //Wait till address is transmitted while !IFS3bits.MI2C2IF ; // read first byte for i 1;i < length;i++ // read further bytes if requested AckI2C2 ;
24lc512 datasheet
Tags: Turn 24lc512 datasheet
| Some Articles: 24lc512 datasheet | Original post: 24lc512 datasheet | Technorati tag: 24lc512 datasheet | Virgilio tag: 24lc512 datasheet
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home