AnsweredAssumed Answered

LPC1769 I2C1 + EEPROM 24LC64 - LPCXpresso LPC1769 Rev.D board

Question asked by Jakub Papuga-Szalapski on Oct 3, 2016
Latest reply on Oct 23, 2016 by Jakub Papuga-Szalapski

Hi all,

 

I need to use EEPROM memory Microchip 24LC64 (64 kb/8 kB) built-in  in LPCXpresso LPC17659 Rev. D PC board for storage some settings data when power is turned off.

 

This EEPROM memory is connected to the I2C number 1 (I2C1) of the LPC1769 microcontroller on the LPCXpresso Rev. D PC board. Memory is not Write Protected (WP pin is connected to the GND) and the EEPROM device address is 0 (binary 000 - pins A2, A1 and A0 are connected to the GND).

 

I wrote some start C code to run I2C1 interface but there is no response from the EEPROM memory.

I read the I2STAT of I2C1 interface and it gave me 0xF8 value - it means some miscellaneous state: no revelant information is available because the serial interrupt flag, SI, is not yet set.

 

I connected oscilloscopes' probes to theEEPROM pins SCL and SDA and I run my simpy C code but thereare no changes on the lines - all the time both are in high level.

 

Below I send my simply C code for I2C1:

 

void I2C1_Init_100kHz (void)
{
LPC_SC->PCONP |= (1<<19); // Turn on power for I2C1

LPC_PINCON->PINSEL1 |= (1<<6); // Set pin P0.19 as SDA1 I2C1
LPC_PINCON->PINSEL1 |= (1<<7); // Set pin P0.19 as SDA1 I2C1
LPC_PINCON->PINSEL1 |= (1<<8); // Set pin P0.20 as SCL1 I2C1
LPC_PINCON->PINSEL1 |= (1<<9); // Set pin P0.20 as SCL1 I2C1

LPC_SC->PCLKSEL1 |= (1<<6); // Turn on clock signal for I2C1; bits 6 i 7
LPC_SC->PCLKSEL1 &=~(1<<7); // Turn on clock signal for I2C1; bits 6 i 7
/* values: 00 - PCLK I2C1 = CCLK/4
* 01 - PCLK I2C1 = CCLK
* 10 - PCLK I2C1 = CCLK/2
* 11 - PCLK I2C1 = CCLK/8
* where: x - MSb (e.g. PCLK_I2C1 it bit 7)
* x - LSb (e.g. PCLK_I2C1 is bit 6)
* CCLK - Core CLK = 100 MHz -> PCLK I2C1 = 100 MHz/1 = 100 MHz
*/

// Set 100 kHz I2C1 frequency with 50 % of Duty Cycle
LPC_I2C1->I2SCLH = 500; // High register of Duty Cycles number
LPC_I2C1->I2SCLL = 500; // Low register of Duty Cycles number

LPC_I2C1->I2CONCLR |= ( (1<<2) | (1<<5) | (1<<6) ); // Clear all bits: 2 - (AAC) Assert Acknowledge bit
// 3 - (SIC) I2C Interrupt bit
// 4 - bit is reserved (do not write to this bit)
// 5 - (STAC) Start Flag bit
// 6 - (I2CENC) I2C Interface Disable bit

// Do a dummy byte transmit - just for test the I2C1 signals (SCL1 and SDA1) with oscilloscope
LPC_I2C1->I2CONSET |= (1<<6); // Turn on the I2C1 interface; set bit 6 - I2C1 Enable bit to 1
Timer0_MicroSeconds (10000); // Time delay - 100 us

LPC_I2C1->I2CONSET |= (1<<5); // START condition is send; set bit 5 - I2C1 STA bit to 1
LPC_I2C1->I2CONCLR |= (1<<3); // Clear the I2C Interrupt bit; clear bit 3 - I2C1 SIC

LPC_I2C1->I2DAT = 0xA0; // Send control byte: 0xA0 = 1010 0000 => 1010 - Control Code
// 000 - Chip Select bits (Device Address)
// 0 - Read or notWrite (1: Read; 0: Write)
// Wait for complete data sending
while ( !( LPC_I2C0->I2CONSET & (1<<3) ) );
LPC_I2C0->I2CONCLR |= (1<<5); // Clear the STAC bit - clear START condition bit
}

Do you have any idea what is wrong with my code?

I will be very helpful for help.

Outcomes