<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic i2c receiving problem in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/i2c-receiving-problem/m-p/951203#M37793</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am using LPC824&amp;nbsp; mcuxpresso IDE&amp;nbsp; , I need 4 sensor value in 16 bit resolution for that i choosen the ADS 1115 adc sensor i2c protocol. I couldn't read the value from the sensor i dont know why?&amp;nbsp; . i provided my code which used to take my o/p . plz let me know the solution for my below code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;===============================================================================&lt;BR /&gt; Name : Example_I2C_Wakeup_Master.c&lt;BR /&gt; Author : $(author)&lt;BR /&gt; Version :&lt;BR /&gt; Copyright : $(copyright)&lt;BR /&gt; Description : main definition&lt;BR /&gt;===============================================================================&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;//#ifdef __USE_CMSIS&lt;BR /&gt;#include "LPC8xx.h"&lt;BR /&gt;//#endif&lt;/P&gt;&lt;P&gt;//#include &amp;lt;cr_section_macros.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include "lpc8xx_i2c.h"&lt;BR /&gt;#include "lpc8xx_syscon.h"&lt;BR /&gt;#include "lpc8xx_swm.h"&lt;BR /&gt;#include "utilities.h"&lt;/P&gt;&lt;P&gt;extern void setup_debug_uart(void);&lt;BR /&gt;#define BUFFER_SIZE 35&lt;BR /&gt;#define WaitForUART0txRdy while(((LPC_USART0-&amp;gt;STAT) &amp;amp; (1&amp;lt;&amp;lt;2)) == 0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void setup_debug_uart(void);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; unsigned char the_prompt[] = "Enter some characters to be transmitted from the I2C master to the slave\n\r";&lt;BR /&gt; unsigned char the_massage[] = "Characters received by the I2C slave were \n\r";&lt;BR /&gt;unsigned char u0_rx_buffer[BUFFER_SIZE];&lt;BR /&gt;unsigned char slave_rx_data[BUFFER_SIZE];&lt;BR /&gt;volatile enum {false, true} uart_handshake;&lt;/P&gt;&lt;P&gt;static uint32_t rx_char_counter = 0;&lt;BR /&gt;static uint32_t slave_data_counter = 0;&lt;BR /&gt;// Program flow&lt;BR /&gt;// 1. Configure I2C0 as master (requires external connections with I2C0 on the slave board, don't forget the external pull-ups.&lt;BR /&gt;// 2. Prompt the user to type a character ('0', '1', or '2') then [Return]&lt;BR /&gt;// 3. Transmit the character on I2C0 to the slave board's I2C0 address to put the slave to sleep.&lt;BR /&gt;// 4. Prompt the user to type [Esc] to proceed with waking up the slave.&lt;BR /&gt;// 5. Transmit the slave board's address to wake up the slave.&lt;/P&gt;&lt;P&gt;#define slave_board_address 0x48&lt;/P&gt;&lt;P&gt;const char promptstring[] = "IOT I2C ADC list:\n\r ADC 0:\n\r ADC 1:\n\r ADC 2:\n\r ADC 3:\n\r";&lt;/P&gt;&lt;P&gt;void UART0_IRQHandler() {&lt;BR /&gt; unsigned char temp;&lt;/P&gt;&lt;P&gt;temp = LPC_USART0-&amp;gt;RXDAT ;&lt;BR /&gt; u0_rx_buffer[rx_char_counter] = temp; // Append the current character to the rx_buffer&lt;BR /&gt; WaitForUART0txRdy; // Wait for TXREADY&lt;BR /&gt; LPC_USART0-&amp;gt;TXDAT = temp; // Echo it back to the terminal&lt;/P&gt;&lt;P&gt;if (temp == 0x0D) { // CR (carriage return) is current character. End of string.&lt;BR /&gt; u0_rx_buffer[rx_char_counter+1] = 0x0A; // Append a new line character to u0_rx_buffer.&lt;BR /&gt; u0_rx_buffer[rx_char_counter+2] = 0x00; // Append a NUL terminator character to u0_rx_buffer to complete the string.&lt;BR /&gt; WaitForUART0txRdy; // Wait for TXREADY&lt;BR /&gt; LPC_USART0-&amp;gt;TXDAT = 0x0A; // Echo a NL (new line) character to the terminal.&lt;BR /&gt; uart_handshake = true; // Set handshake for main()&lt;BR /&gt; rx_char_counter = 0; // Clear array index counter&lt;BR /&gt; }&lt;BR /&gt; else { // Current character is not CR, keep collecting them.&lt;BR /&gt; rx_char_counter++; // Increment array index counter.&lt;/P&gt;&lt;P&gt;if (rx_char_counter == BUFFER_SIZE) // If the string overruns the buffer, stop here before all hell breaks lose.&lt;BR /&gt; while(1);&lt;BR /&gt; }&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt;** Function name: I2C0_IRQHandler&lt;BR /&gt;**&lt;BR /&gt;** Descriptions: I2C0 interrupt service routine.&lt;BR /&gt;**&lt;BR /&gt;** parameters: None&lt;BR /&gt;** Returned value: None&lt;BR /&gt;**&lt;BR /&gt;*****************************************************************************/&lt;/P&gt;&lt;P&gt;void I2C0_IRQHandler(void) {&lt;BR /&gt; uint32_t temp;&lt;/P&gt;&lt;P&gt;/*if ((LPC_I2C0-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) == STAT_MSTIDLE) {&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE; // ACK the address&lt;BR /&gt; return;&lt;BR /&gt; }*/&lt;/P&gt;&lt;P&gt;if ((LPC_I2C0-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) == STAT_MSTRX) {&lt;BR /&gt; temp = LPC_I2C0-&amp;gt;MSTDAT; // Read the data&lt;BR /&gt; slave_rx_data[slave_data_counter++] = temp; // Store it in the array, increment counter&lt;BR /&gt;//PutTerminalString(LPC_USART0,slave_rx_data);&lt;BR /&gt;//PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_SLVCONTINUE; // ACK the data&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX);&lt;BR /&gt; PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; // Send a stop to end the transaction&lt;BR /&gt; // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;BR /&gt; // PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; if (temp == 0) // If current char is NUL terminator&lt;BR /&gt; slave_data_counter = 0; // clear the counter for next string&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; // Any other slave state, stop here and debug&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int main(void) {&lt;/P&gt;&lt;P&gt;int temp;&lt;BR /&gt; unsigned int abc= 3,abc1=5009,abc2=5,abc3=6;&lt;BR /&gt; int a="ABCDEFGHIJKLMN1234567/n";&lt;BR /&gt; &lt;BR /&gt; setup_debug_uart();&lt;/P&gt;&lt;P&gt;// Enable clocks to I2C, SWM (see lpc8xx_syscon.h)&lt;BR /&gt; LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (I2C0|SWM);&lt;/P&gt;&lt;P&gt;// SWM settings for I2C0 (master):&lt;BR /&gt; // P0.10 = I2C0_SCL&lt;BR /&gt; // P0.11 = I2C0_SDA&lt;BR /&gt; LPC_SWM-&amp;gt;PINENABLE0 &amp;amp;= ~(I2C0_SCL|I2C0_SDA); // Use for LPC824&lt;BR /&gt; // Give I2C a reset (see lpc8xx_syscon.h)&lt;BR /&gt; LPC_SYSCON-&amp;gt;PRESETCTRL &amp;amp;= (I2C0_RST_N);&lt;BR /&gt; LPC_SYSCON-&amp;gt;PRESETCTRL |= ~(I2C0_RST_N);&lt;/P&gt;&lt;P&gt;// PutTerminalchar(LPC_USART0, abc);&lt;BR /&gt; // PutTerminalString(LPC_USART0, (uint8_t *) the_prompt); // IOT PROJECT STRING&lt;/P&gt;&lt;P&gt;// Configure the I2C clock divider&lt;BR /&gt; // Desired bit rate = Fscl = 100,000 Hz&lt;BR /&gt; // Use default clock high and clock low times (= 2 clocks each)&lt;BR /&gt; // So 4 I2C_PCLKs = 100,000/second, or 1 I2C_PCLK = 400,000/second&lt;BR /&gt; // I2C_PCLK = SystemClock = 30,000,000/second, so we divide by 30/.4 = 75&lt;BR /&gt; // Remember, value written to DIV divides by value+1&lt;BR /&gt; //&lt;BR /&gt; LPC_I2C0-&amp;gt;DIV = (75-1);&lt;BR /&gt; // LPC_I2C0-&amp;gt;DIV = (30-1);&lt;BR /&gt; // Configure the I2C CFG register:&lt;BR /&gt; // Master enable = true&lt;BR /&gt; // Slave enable = false&lt;BR /&gt; // Monitor enable = false&lt;BR /&gt; // Time-out enable = false&lt;BR /&gt; // Monitor function clock stretching = false&lt;BR /&gt; //&lt;BR /&gt; LPC_I2C0-&amp;gt;CFG = CFG_MSTENA;&lt;BR /&gt;// LPC_I2C0-&amp;gt;MSTDAT = (slave_board_address&amp;lt;&amp;lt;1) | 1;&lt;BR /&gt; //Config_LEDs(GREEN|RED|BLUE);&lt;BR /&gt;//LPC_I2C0-&amp;gt;INTENSET = STAT_SLVPEND;&lt;BR /&gt;LPC_I2C0-&amp;gt;INTENSET = STAT_MSTPEND;&lt;BR /&gt; //NVIC_EnableIRQ(I2C0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; while(1) {&lt;/P&gt;&lt;P&gt;// LEDs_On(GREEN);&lt;/P&gt;&lt;P&gt;// Prompt user to select a low-power mode for the slave (see utilities_lib)&lt;BR /&gt; temp = GetConsoleCharacter((const char *)&amp;amp;promptstring);&lt;/P&gt;&lt;P&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;BR /&gt; NVIC_EnableIRQ(I2C0_IRQn);&lt;BR /&gt; &lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void WaitI2CMasterState(LPC_I2C_TypeDef * ptr_LPC_I2C, uint32_t state) {&lt;/P&gt;&lt;P&gt;while(!(ptr_LPC_I2C-&amp;gt;STAT &amp;amp; STAT_MSTPEND)); // Wait for MSTPENDING bit set in STAT register&lt;BR /&gt;if((ptr_LPC_I2C-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) != state) { // If master state mismatch ...&lt;BR /&gt;LEDs_Off(GREEN);&lt;BR /&gt;LEDs_On(RED);&lt;BR /&gt;while(1); // die here and debug the problem&lt;BR /&gt;}&lt;BR /&gt;return; // If no mismatch, return&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; */&lt;BR /&gt; } // end of while(1)&lt;/P&gt;&lt;P&gt;} // end of main&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 07 Jul 2019 08:04:23 GMT</pubDate>
    <dc:creator>aravindpb5009</dc:creator>
    <dc:date>2019-07-07T08:04:23Z</dc:date>
    <item>
      <title>i2c receiving problem</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/i2c-receiving-problem/m-p/951203#M37793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am using LPC824&amp;nbsp; mcuxpresso IDE&amp;nbsp; , I need 4 sensor value in 16 bit resolution for that i choosen the ADS 1115 adc sensor i2c protocol. I couldn't read the value from the sensor i dont know why?&amp;nbsp; . i provided my code which used to take my o/p . plz let me know the solution for my below code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;===============================================================================&lt;BR /&gt; Name : Example_I2C_Wakeup_Master.c&lt;BR /&gt; Author : $(author)&lt;BR /&gt; Version :&lt;BR /&gt; Copyright : $(copyright)&lt;BR /&gt; Description : main definition&lt;BR /&gt;===============================================================================&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;//#ifdef __USE_CMSIS&lt;BR /&gt;#include "LPC8xx.h"&lt;BR /&gt;//#endif&lt;/P&gt;&lt;P&gt;//#include &amp;lt;cr_section_macros.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include "lpc8xx_i2c.h"&lt;BR /&gt;#include "lpc8xx_syscon.h"&lt;BR /&gt;#include "lpc8xx_swm.h"&lt;BR /&gt;#include "utilities.h"&lt;/P&gt;&lt;P&gt;extern void setup_debug_uart(void);&lt;BR /&gt;#define BUFFER_SIZE 35&lt;BR /&gt;#define WaitForUART0txRdy while(((LPC_USART0-&amp;gt;STAT) &amp;amp; (1&amp;lt;&amp;lt;2)) == 0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void setup_debug_uart(void);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; unsigned char the_prompt[] = "Enter some characters to be transmitted from the I2C master to the slave\n\r";&lt;BR /&gt; unsigned char the_massage[] = "Characters received by the I2C slave were \n\r";&lt;BR /&gt;unsigned char u0_rx_buffer[BUFFER_SIZE];&lt;BR /&gt;unsigned char slave_rx_data[BUFFER_SIZE];&lt;BR /&gt;volatile enum {false, true} uart_handshake;&lt;/P&gt;&lt;P&gt;static uint32_t rx_char_counter = 0;&lt;BR /&gt;static uint32_t slave_data_counter = 0;&lt;BR /&gt;// Program flow&lt;BR /&gt;// 1. Configure I2C0 as master (requires external connections with I2C0 on the slave board, don't forget the external pull-ups.&lt;BR /&gt;// 2. Prompt the user to type a character ('0', '1', or '2') then [Return]&lt;BR /&gt;// 3. Transmit the character on I2C0 to the slave board's I2C0 address to put the slave to sleep.&lt;BR /&gt;// 4. Prompt the user to type [Esc] to proceed with waking up the slave.&lt;BR /&gt;// 5. Transmit the slave board's address to wake up the slave.&lt;/P&gt;&lt;P&gt;#define slave_board_address 0x48&lt;/P&gt;&lt;P&gt;const char promptstring[] = "IOT I2C ADC list:\n\r ADC 0:\n\r ADC 1:\n\r ADC 2:\n\r ADC 3:\n\r";&lt;/P&gt;&lt;P&gt;void UART0_IRQHandler() {&lt;BR /&gt; unsigned char temp;&lt;/P&gt;&lt;P&gt;temp = LPC_USART0-&amp;gt;RXDAT ;&lt;BR /&gt; u0_rx_buffer[rx_char_counter] = temp; // Append the current character to the rx_buffer&lt;BR /&gt; WaitForUART0txRdy; // Wait for TXREADY&lt;BR /&gt; LPC_USART0-&amp;gt;TXDAT = temp; // Echo it back to the terminal&lt;/P&gt;&lt;P&gt;if (temp == 0x0D) { // CR (carriage return) is current character. End of string.&lt;BR /&gt; u0_rx_buffer[rx_char_counter+1] = 0x0A; // Append a new line character to u0_rx_buffer.&lt;BR /&gt; u0_rx_buffer[rx_char_counter+2] = 0x00; // Append a NUL terminator character to u0_rx_buffer to complete the string.&lt;BR /&gt; WaitForUART0txRdy; // Wait for TXREADY&lt;BR /&gt; LPC_USART0-&amp;gt;TXDAT = 0x0A; // Echo a NL (new line) character to the terminal.&lt;BR /&gt; uart_handshake = true; // Set handshake for main()&lt;BR /&gt; rx_char_counter = 0; // Clear array index counter&lt;BR /&gt; }&lt;BR /&gt; else { // Current character is not CR, keep collecting them.&lt;BR /&gt; rx_char_counter++; // Increment array index counter.&lt;/P&gt;&lt;P&gt;if (rx_char_counter == BUFFER_SIZE) // If the string overruns the buffer, stop here before all hell breaks lose.&lt;BR /&gt; while(1);&lt;BR /&gt; }&lt;BR /&gt; return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt;** Function name: I2C0_IRQHandler&lt;BR /&gt;**&lt;BR /&gt;** Descriptions: I2C0 interrupt service routine.&lt;BR /&gt;**&lt;BR /&gt;** parameters: None&lt;BR /&gt;** Returned value: None&lt;BR /&gt;**&lt;BR /&gt;*****************************************************************************/&lt;/P&gt;&lt;P&gt;void I2C0_IRQHandler(void) {&lt;BR /&gt; uint32_t temp;&lt;/P&gt;&lt;P&gt;/*if ((LPC_I2C0-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) == STAT_MSTIDLE) {&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE; // ACK the address&lt;BR /&gt; return;&lt;BR /&gt; }*/&lt;/P&gt;&lt;P&gt;if ((LPC_I2C0-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) == STAT_MSTRX) {&lt;BR /&gt; temp = LPC_I2C0-&amp;gt;MSTDAT; // Read the data&lt;BR /&gt; slave_rx_data[slave_data_counter++] = temp; // Store it in the array, increment counter&lt;BR /&gt;//PutTerminalString(LPC_USART0,slave_rx_data);&lt;BR /&gt;//PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_SLVCONTINUE; // ACK the data&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX);&lt;BR /&gt; PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; // Send a stop to end the transaction&lt;BR /&gt; // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;BR /&gt; // PutTerminalchar1(LPC_USART0, (uint8_t*)slave_rx_data);&lt;BR /&gt; if (temp == 0) // If current char is NUL terminator&lt;BR /&gt; slave_data_counter = 0; // clear the counter for next string&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; // Any other slave state, stop here and debug&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;int main(void) {&lt;/P&gt;&lt;P&gt;int temp;&lt;BR /&gt; unsigned int abc= 3,abc1=5009,abc2=5,abc3=6;&lt;BR /&gt; int a="ABCDEFGHIJKLMN1234567/n";&lt;BR /&gt; &lt;BR /&gt; setup_debug_uart();&lt;/P&gt;&lt;P&gt;// Enable clocks to I2C, SWM (see lpc8xx_syscon.h)&lt;BR /&gt; LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (I2C0|SWM);&lt;/P&gt;&lt;P&gt;// SWM settings for I2C0 (master):&lt;BR /&gt; // P0.10 = I2C0_SCL&lt;BR /&gt; // P0.11 = I2C0_SDA&lt;BR /&gt; LPC_SWM-&amp;gt;PINENABLE0 &amp;amp;= ~(I2C0_SCL|I2C0_SDA); // Use for LPC824&lt;BR /&gt; // Give I2C a reset (see lpc8xx_syscon.h)&lt;BR /&gt; LPC_SYSCON-&amp;gt;PRESETCTRL &amp;amp;= (I2C0_RST_N);&lt;BR /&gt; LPC_SYSCON-&amp;gt;PRESETCTRL |= ~(I2C0_RST_N);&lt;/P&gt;&lt;P&gt;// PutTerminalchar(LPC_USART0, abc);&lt;BR /&gt; // PutTerminalString(LPC_USART0, (uint8_t *) the_prompt); // IOT PROJECT STRING&lt;/P&gt;&lt;P&gt;// Configure the I2C clock divider&lt;BR /&gt; // Desired bit rate = Fscl = 100,000 Hz&lt;BR /&gt; // Use default clock high and clock low times (= 2 clocks each)&lt;BR /&gt; // So 4 I2C_PCLKs = 100,000/second, or 1 I2C_PCLK = 400,000/second&lt;BR /&gt; // I2C_PCLK = SystemClock = 30,000,000/second, so we divide by 30/.4 = 75&lt;BR /&gt; // Remember, value written to DIV divides by value+1&lt;BR /&gt; //&lt;BR /&gt; LPC_I2C0-&amp;gt;DIV = (75-1);&lt;BR /&gt; // LPC_I2C0-&amp;gt;DIV = (30-1);&lt;BR /&gt; // Configure the I2C CFG register:&lt;BR /&gt; // Master enable = true&lt;BR /&gt; // Slave enable = false&lt;BR /&gt; // Monitor enable = false&lt;BR /&gt; // Time-out enable = false&lt;BR /&gt; // Monitor function clock stretching = false&lt;BR /&gt; //&lt;BR /&gt; LPC_I2C0-&amp;gt;CFG = CFG_MSTENA;&lt;BR /&gt;// LPC_I2C0-&amp;gt;MSTDAT = (slave_board_address&amp;lt;&amp;lt;1) | 1;&lt;BR /&gt; //Config_LEDs(GREEN|RED|BLUE);&lt;BR /&gt;//LPC_I2C0-&amp;gt;INTENSET = STAT_SLVPEND;&lt;BR /&gt;LPC_I2C0-&amp;gt;INTENSET = STAT_MSTPEND;&lt;BR /&gt; //NVIC_EnableIRQ(I2C0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; while(1) {&lt;/P&gt;&lt;P&gt;// LEDs_On(GREEN);&lt;/P&gt;&lt;P&gt;// Prompt user to select a low-power mode for the slave (see utilities_lib)&lt;BR /&gt; temp = GetConsoleCharacter((const char *)&amp;amp;promptstring);&lt;/P&gt;&lt;P&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;BR /&gt; NVIC_EnableIRQ(I2C0_IRQn);&lt;BR /&gt; &lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void WaitI2CMasterState(LPC_I2C_TypeDef * ptr_LPC_I2C, uint32_t state) {&lt;/P&gt;&lt;P&gt;while(!(ptr_LPC_I2C-&amp;gt;STAT &amp;amp; STAT_MSTPEND)); // Wait for MSTPENDING bit set in STAT register&lt;BR /&gt;if((ptr_LPC_I2C-&amp;gt;STAT &amp;amp; MASTER_STATE_MASK) != state) { // If master state mismatch ...&lt;BR /&gt;LEDs_Off(GREEN);&lt;BR /&gt;LEDs_On(RED);&lt;BR /&gt;while(1); // die here and debug the problem&lt;BR /&gt;}&lt;BR /&gt;return; // If no mismatch, return&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; */&lt;BR /&gt; } // end of while(1)&lt;/P&gt;&lt;P&gt;} // end of main&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Jul 2019 08:04:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/i2c-receiving-problem/m-p/951203#M37793</guid>
      <dc:creator>aravindpb5009</dc:creator>
      <dc:date>2019-07-07T08:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: i2c receiving problem</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/i2c-receiving-problem/m-p/951204#M37794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A _jive_internal="true" data-content-finding="Community" data-userid="342073" data-username="aravindpb5009@gmail.com" href="https://community.nxp.com/people/aravindpb5009@gmail.com"&gt;Aravind palanisamy&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;First of all, I recommend you use a Logic analyzer to analysis the two singles I2C_SDA and I2C_SCL,&lt;/P&gt;&lt;P&gt;check whether it is right.&lt;/P&gt;&lt;P&gt;Then there is I2C demo under LPCopen about lpc824, you can refer to:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/support/developer-resources/microcontrollers-developer-resources/lpcopen-libraries-and-examples/lpcopen-software-development-platform-lpc8xx:LPCOPEN-SOFTWARE-FOR-LPC8XX" title="https://www.nxp.com/support/developer-resources/microcontrollers-developer-resources/lpcopen-libraries-and-examples/lpcopen-software-development-platform-lpc8xx:LPCOPEN-SOFTWARE-FOR-LPC8XX"&gt;LPCOpen Software for LPC8XX | NXP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2019 09:03:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/i2c-receiving-problem/m-p/951204#M37794</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2019-07-08T09:03:11Z</dc:date>
    </item>
  </channel>
</rss>

