<?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>LPC Microcontrollersのトピックlpc824 external adc reading?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956891#M37968</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I need to read ADS1115 sensor values through the i2c protocol . i am, using lpc824 mcuxpresso i am, try last 2 week referred the ads1115 datasheet and lpc824 datasheet. but i got only junk values , please let me know the solution to correct my faults.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;plz refer my code and give me somr solution i am asking this assistance last 2 week but till i couldn't get proper o/p&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;i refered lpc example coding which provided&amp;nbsp; in the mcuxpresso ide but in that code also i didn't got any proper solution . in that examples code there is no adc reading code in i2c plz give the solution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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;&lt;BR /&gt;&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;BR /&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; SLAVE_STATE_MASK) == STAT_SLVADDR) {&lt;BR /&gt; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the address&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((LPC_I2C0-&amp;gt;STAT &amp;amp; SLAVE_STATE_MASK) == STAT_SLVRX) {&lt;BR /&gt; temp = LPC_I2C0-&amp;gt;SLVDAT; // 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; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the 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; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;while(1); // Any other slave state, stop here and debug&lt;BR /&gt;}&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;void I2C0_IRQHandler(void) {&lt;BR /&gt; uint32_t temp=0;&lt;BR /&gt;unsigned int five=50009;&lt;BR /&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; PutTerminalchar2(LPC_USART0,slave_rx_data);&lt;BR /&gt; // PutTerminalchar2(LPC_USART0, five);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_SLVCONTINUE; // ACK the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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; return;&lt;BR /&gt; }&lt;BR /&gt; //while(1); // 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,temp1=0;&lt;BR /&gt; unsigned int abc= 3,abc1=5009,abc2=5,abc3=6;&lt;BR /&gt; int a="ABCDEFGHIJKLMN1234567/n";&lt;BR /&gt; // Configure the debug uart (see Serial.c)&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_SDA0&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; &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; //NVIC_EnableIRQ(I2C0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; while(1) {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;STRONG&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_IDLE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LPC_I2C0-&amp;gt;MSTDAT = (slave_board_address&amp;lt;&amp;lt;1) |1; //// ( read )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART; // Start the transaction.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;temp1 = LPC_I2C0-&amp;gt;MSTDAT;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; slave_rx_data[slave_data_counter++] = temp1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PutTerminalchar2(LPC_USART0,(uint8_t*)slave_rx_data);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (temp1 == 0) // If current char is NUL terminator&lt;BR /&gt; {&lt;BR /&gt; slave_data_counter = 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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>Tue, 09 Jul 2019 05:40:52 GMT</pubDate>
    <dc:creator>aravindpb5009</dc:creator>
    <dc:date>2019-07-09T05:40:52Z</dc:date>
    <item>
      <title>lpc824 external adc reading?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956891#M37968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hai&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I need to read ADS1115 sensor values through the i2c protocol . i am, using lpc824 mcuxpresso i am, try last 2 week referred the ads1115 datasheet and lpc824 datasheet. but i got only junk values , please let me know the solution to correct my faults.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;plz refer my code and give me somr solution i am asking this assistance last 2 week but till i couldn't get proper o/p&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;i refered lpc example coding which provided&amp;nbsp; in the mcuxpresso ide but in that code also i didn't got any proper solution . in that examples code there is no adc reading code in i2c plz give the solution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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;&lt;BR /&gt;&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;BR /&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; SLAVE_STATE_MASK) == STAT_SLVADDR) {&lt;BR /&gt; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the address&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((LPC_I2C0-&amp;gt;STAT &amp;amp; SLAVE_STATE_MASK) == STAT_SLVRX) {&lt;BR /&gt; temp = LPC_I2C0-&amp;gt;SLVDAT; // 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; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the 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; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;while(1); // Any other slave state, stop here and debug&lt;BR /&gt;}&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;void I2C0_IRQHandler(void) {&lt;BR /&gt; uint32_t temp=0;&lt;BR /&gt;unsigned int five=50009;&lt;BR /&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; PutTerminalchar2(LPC_USART0,slave_rx_data);&lt;BR /&gt; // PutTerminalchar2(LPC_USART0, five);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_SLVCONTINUE; // ACK the data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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; return;&lt;BR /&gt; }&lt;BR /&gt; //while(1); // 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,temp1=0;&lt;BR /&gt; unsigned int abc= 3,abc1=5009,abc2=5,abc3=6;&lt;BR /&gt; int a="ABCDEFGHIJKLMN1234567/n";&lt;BR /&gt; // Configure the debug uart (see Serial.c)&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_SDA0&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; &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; //NVIC_EnableIRQ(I2C0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; while(1) {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;STRONG&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_IDLE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LPC_I2C0-&amp;gt;MSTDAT = (slave_board_address&amp;lt;&amp;lt;1) |1; //// ( read )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART; // Start the transaction.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;temp1 = LPC_I2C0-&amp;gt;MSTDAT;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; slave_rx_data[slave_data_counter++] = temp1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PutTerminalchar2(LPC_USART0,(uint8_t*)slave_rx_data);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX );&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (temp1 == 0) // If current char is NUL terminator&lt;BR /&gt; {&lt;BR /&gt; slave_data_counter = 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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>Tue, 09 Jul 2019 05:40:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956891#M37968</guid>
      <dc:creator>aravindpb5009</dc:creator>
      <dc:date>2019-07-09T05:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: lpc824 external adc reading?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956892#M37969</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;About reading data from ADS1115, please refer to the datasheet of ADS1115 -&amp;gt;&amp;nbsp; reading from registers sequence part:&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;To access a specific register from the ADS111x, the master must first write an appropriate value to register&lt;BR /&gt;address pointer bits P[1:0] in the Address Pointer register. The Address Pointer register is written to directly after&lt;BR /&gt;the slave address byte, low R/W bit, and a successful slave acknowledgment. After the Address Pointer register&lt;BR /&gt;is written, the slave acknowledges, and the master issues a STOP or a repeated START condition.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;When reading from the ADS111x&lt;/STRONG&gt;, the previous value written to bits P[1:0] determines the register that is read. To&lt;BR /&gt;change which register is read, a new value must be written to P[1:0]. &lt;SPAN style="color: #ff0000;"&gt;To write a new value to P[1:0], the master&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;issues a slave address byte with the R/W bit low, followed by the Address Pointer register byte.&lt;/SPAN&gt; No additional&lt;BR /&gt;data has to be transmitted, and a STOP condition can be issued by the master. The master can now issue a&lt;BR /&gt;START condition and send the slave address byte with the R/W bit high to begin the read. Figure 37 details this&lt;BR /&gt;sequence. If repeated reads from the same register are desired, there is no need to continually send the Address&lt;BR /&gt;Pointer register, because the ADS111x store the value of P[1:0] until it is modified by a write operation. However,&lt;BR /&gt;for every write operation, the Address Pointer register must be written with the appropriate values.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;" Also refer to the Figure 30.Timing Diagram for Reading From ADS111x .&lt;/P&gt;&lt;P&gt;In your code , I haven't see write " slave address byte", and " write an appropriate value to register&lt;BR /&gt;address pointer bits P[1:0] in the Address Pointer register."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if still have problem, suggest you use a logic analysis signals, compare with Fig 30 of ADS1115 datasheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps,&lt;/P&gt;&lt;P&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>Tue, 16 Jul 2019 08:56:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956892#M37969</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2019-07-16T08:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: lpc824 external adc reading?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956893#M37970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THIS is my updated code but this also doesn't work&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;===============================================================================&lt;BR /&gt; Name : Example_I2C_MasterSlave.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;#include "LPC8xx.h"&lt;BR /&gt;//#include &amp;lt;cr_section_macros.h&amp;gt;&lt;BR /&gt;//#include &amp;lt;stdio.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include "lpc8xx_i2c.h"&lt;BR /&gt;#include "lpc8xx_swm.h"&lt;BR /&gt;#include "lpc8xx_syscon.h"&lt;BR /&gt;#include "utilities.h"&lt;/P&gt;&lt;P&gt;&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;BR /&gt; #define Self_Slave_address 0x48U&lt;BR /&gt; #define ADS1015_REG_POINTER_MASK (0x03)&lt;BR /&gt; #define ADS1015_REG_POINTER_CONVERT (0x00)&lt;BR /&gt; #define ADS1015_REG_POINTER_CONFIG (0x01)&lt;BR /&gt; #define ADS1015_REG_POINTER_LOWTHRESH (0x02)&lt;BR /&gt; #define ADS1015_REG_POINTER_HITHRESH (0x03)&lt;BR /&gt; #define config_high 0x84&lt;BR /&gt; #define config_low 0x83&lt;BR /&gt; #define config_line 0x0083&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;const unsigned char the_prompt[] = "Enter some characters to be transmitted from the I2C master to the slave\n\r";&lt;BR /&gt;const unsigned char the_massage[] = "Characters received by the I2C slave were \n\r";&lt;BR /&gt;const unsigned char start_bit[] = "Startbit \n\r";&lt;BR /&gt;const unsigned char stop_bit[] = "Stopbit \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;unsigned int slave_rx_data[BUFFER_SIZE];&lt;BR /&gt;unsigned char TEMP1[]="5";&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;/P&gt;&lt;P&gt;&lt;BR /&gt;/*****************************************************************************&lt;BR /&gt;** Function name: UART0_IRQHandler&lt;BR /&gt;**&lt;BR /&gt;** Description: UART0 interrupt service routine.&lt;BR /&gt;** This ISR reads one received char from the UART0 RXDAT register,&lt;BR /&gt;** appends it to the u0_rx_buffer array, and echos it back via the&lt;BR /&gt;** UART0 transmitter. If the char. is 0xD (carriage return),&lt;BR /&gt;** a new line char (0xA) is appended to the array and echoed,&lt;BR /&gt;** then a NUL char (0x0) is appended to the array to terminate the string&lt;BR /&gt;** for future use.&lt;BR /&gt;**&lt;BR /&gt;** Parameters: None&lt;BR /&gt;** Returned value: void&lt;BR /&gt;**&lt;BR /&gt;*****************************************************************************/&lt;BR /&gt;void UART0_IRQHandler() {&lt;BR /&gt; unsigned char temp;&lt;/P&gt;&lt;P&gt;&lt;BR /&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;BR /&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; SLAVE_STATE_MASK) == STAT_SLVADDR) {&lt;BR /&gt; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the address&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((LPC_I2C0-&amp;gt;STAT &amp;amp; SLAVE_STATE_MASK) == STAT_SLVRX) {&lt;BR /&gt; temp = LPC_I2C0-&amp;gt;SLVDAT; // Read the data&lt;BR /&gt; slave_rx_data[slave_data_counter++] = temp; // Store it in the array, increment counter&lt;BR /&gt; PutTerminalNUM(LPC_USART0, TEMP1);&lt;BR /&gt; LPC_I2C0-&amp;gt;SLVCTL = CTL_SLVCONTINUE; // ACK the 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; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;while(1); // Any other slave state, stop here and debug&lt;BR /&gt;}*/&lt;/P&gt;&lt;P&gt;void I2C0_IRQHandler(void) {&lt;BR /&gt; uint32_t temp;&lt;BR /&gt; unsigned char temp1=5;&lt;/P&gt;&lt;P&gt;&lt;BR /&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, temp1);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE; // ACK the data&lt;/P&gt;&lt;P&gt;WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the data to be ACK'd&lt;BR /&gt; //&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP; // Send a stop to end the transaction&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; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;// while(1); // Any other slave state, stop here and debug&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt;*****************************************************************************/&lt;BR /&gt;int main(void) {&lt;BR /&gt; uint32_t temp ,msb_byte,lsb_byte;&lt;BR /&gt; unsigned char * tx_ptr;&lt;BR /&gt;unsigned int temp1=5009;&lt;BR /&gt; // Configure the debug uart (see Serial.c)&lt;BR /&gt; setup_debug_uart();&lt;/P&gt;&lt;P&gt;// Enable clocks to I2C0, 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:&lt;BR /&gt; // P0.10 = I2C0_SCK&lt;BR /&gt; // P0.11 = I2C0_SDA&lt;/P&gt;&lt;P&gt;// Configure the SWM (see utilities_lib and lpc8xx_swm.h)&lt;BR /&gt; // On the LPC824, I2C0_SDA and I2C0_SCL are fixed pin functions which are enabled / disabled in the pinenable0 register&lt;BR /&gt; LPC_SWM-&amp;gt;PINENABLE0 &amp;amp;= ~(I2C0_SCL|I2C0_SDA); // Use for LPC824&lt;BR /&gt; //ConfigSWM(I2C0_SCL, P0_10); // Use for LPC812&lt;BR /&gt; //ConfigSWM(I2C0_SDA, P0_11); // Use for LPC812&lt;/P&gt;&lt;P&gt;// Give I2C0 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;// Configure the I2C0 clock divider&lt;BR /&gt; // Desired bit rate = Fscl = 100,000 Hz (1/Fscl = 10 us, 5 us low and 5 us high)&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;LPC_I2C0-&amp;gt;DIV = (75 - 1);&lt;BR /&gt;// LPC_I2C0-&amp;gt;DIV = (30 - 1);&lt;BR /&gt; // Configure the I2C0 CFG register:&lt;BR /&gt; // Master enable = true&lt;BR /&gt; // Slave enable = true&lt;BR /&gt; // Monitor enable = false&lt;BR /&gt; // Time-out enable = false&lt;BR /&gt; // Monitor function clock stretching = false&lt;BR /&gt; LPC_I2C0-&amp;gt;CFG = CFG_MSTENA| CFG_SLVENA ;&lt;BR /&gt; // Configure the I2C0 SLVADR3 address register with 0 in l.s.b. to enable slave address 3&lt;BR /&gt;//LPC_I2C0-&amp;gt;SLVADR3 = (Self_Slave_address&amp;lt;&amp;lt;1) | 1;&lt;BR /&gt;LPC_I2C0-&amp;gt;INTENSET = STAT_MSTPEND|STAT_SLVPEND ;&lt;BR /&gt;///////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//////////////////write from master to ADS1115 I2C MODULE/////////////////////////////////////////////&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART; // Start the transaction by setting the MSTSTART bit to 1 in the Master control register.&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = (Self_Slave_address&amp;lt;&amp;lt;1) | 0; // Address with 0 for RWn bit (WRITE)&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX ); // Wait for the address to be ACK'd&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = ADS1015_REG_POINTER_CONFIG; // Address with 0 for RWn bit (WRITE)&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX ); // Wait for the address to be ACK'd&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = config_high; // Address with 0 for RWn bit (WRITE) config&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX ); // Wait for the address to be ACK'd&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT =config_low; // Address with 0 for RWn bit (WRITE) config&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX ); // Wait for the address to be ACK'd&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP; // Send a stop to end the transaction&lt;BR /&gt; // LPC_I2C0-&amp;gt;MSTDAT = ADS1015_REG_POINTER_CONVERT;&lt;BR /&gt; // WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd&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_MSTSTART;&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = (Self_Slave_address&amp;lt;&amp;lt;1) | 0; // Address with 0 for RWn bit (write)&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = ADS1015_REG_POINTER_CONVERT;&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP;&lt;/P&gt;&lt;P&gt;while(1)&lt;BR /&gt; {&lt;BR /&gt;////////////////// write to ads1115 conversion register/////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART;&lt;BR /&gt;// LPC_I2C0-&amp;gt;MSTDAT = (Self_Slave_address&amp;lt;&amp;lt;1) | 0; // Address with 0 for RWn bit (write)&lt;BR /&gt;// WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd&lt;BR /&gt;// //PutTerminalString(LPC_USART0, start_bit);&lt;BR /&gt;// LPC_I2C0-&amp;gt;MSTDAT = ADS1015_REG_POINTER_CONVERT;&lt;BR /&gt;// WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd&lt;BR /&gt;// PutTerminalString(LPC_USART0, start_bit);&lt;BR /&gt;// LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP; // Send a stop to end the transaction&lt;BR /&gt;// // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART; // Start the transaction by setting the MSTSTART bit to 1 in the Master control register.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTART;&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTDAT = (Self_Slave_address&amp;lt;&amp;lt;1) | 1; // Address with 0 for RWn bit (read)&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX);&lt;BR /&gt; msb_byte = LPC_I2C0-&amp;gt;MSTDAT; // Read the data&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX);&lt;BR /&gt; lsb_byte = LPC_I2C0-&amp;gt;MSTDAT; // Read the data&lt;BR /&gt; WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX);&lt;/P&gt;&lt;P&gt;// slave_rx_data[slave_data_counter++] = temp; // Store it in the array, increment counter&lt;BR /&gt; // PutTerminalString1(LPC_USART0, temp1);&lt;BR /&gt; PutTerminalString1(LPC_USART0, msb_byte);&lt;BR /&gt; PutTerminalString1(LPC_USART0, lsb_byte);&lt;BR /&gt; // PutTerminalchar0(LPC_USART0, lsb_byte);&lt;BR /&gt; // LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTCONTINUE; // ACK the data&lt;BR /&gt; // PutTerminalString(LPC_USART0,temp);&lt;BR /&gt; // WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX); // Wait for the data to be ACK'd&lt;BR /&gt; // NVIC_EnableIRQ(I2C0_IRQn);&lt;BR /&gt; LPC_I2C0-&amp;gt;MSTCTL = CTL_MSTSTOP; // Send a stop to end the transaction&lt;BR /&gt; PutTerminalString(LPC_USART0, (uint8_t *)stop_bit);// Print a massage&lt;BR /&gt; } // end of while 1&lt;/P&gt;&lt;P&gt;} // end of main&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/////////////////////////////////////&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 09:26:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc824-external-adc-reading/m-p/956893#M37970</guid>
      <dc:creator>aravindpb5009</dc:creator>
      <dc:date>2019-07-16T09:26:52Z</dc:date>
    </item>
  </channel>
</rss>

