<?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のトピックLPC4370 ADC gives incorrect data</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-ADC-gives-incorrect-data/m-p/623233#M24473</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;we are using LPC4370 with LPCexpresso&amp;nbsp;for high speed meassurement. The microcontroller gives control signals to 4 analog multiplexer (8:1). Simultaneously, the same microcontroller is used for reading the ouput signals of the four multiplexer. The 4 output signals is given to ADC GPIOS. These input GPIOS have the same initialisation. However, just 3 of them works. The last GPIO gives wrong data. Do you have same experiences, any suggestions or tips ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The initialisation code is attached below: &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; USBD_API_INIT_PARAM_T usb_param;&lt;BR /&gt; USB_CORE_DESCS_T desc;&lt;BR /&gt; ErrorCode_t ret = LPC_OK;&lt;BR /&gt; USB_CORE_CTRL_T *pCtrl;&lt;/P&gt;&lt;P&gt;/* Initialize board and chip */&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;/P&gt;&lt;P&gt;/* enable clocks and pinmux */&lt;BR /&gt; USB_init_pin_clk();&lt;/P&gt;&lt;P&gt;/* Setting up the HSADC clock is more complex than other peripherals.&lt;BR /&gt; The HSADC clock is driven directly from the CGU/CCU and has limited&lt;BR /&gt; source and divider options. Because the HSADC clocking is entirely&lt;BR /&gt; handled outside the HSADC peripheral, example code for setting up&lt;BR /&gt; the CGU/CCU to get a rough HSADC clock rate is included in this&lt;BR /&gt; example. */&lt;/P&gt;&lt;P&gt;Chip_USB0_Init(); /* Initialize the USB0 PLL to 480 MHz */&lt;BR /&gt; Chip_Clock_SetDivider(CLK_IDIV_A, CLKIN_USBPLL, 4); /* Source DIV_A from USB0PLL, and set divider to 2 (Max div value supported is 4) [IN 480 MHz; OUT 120 MHz */&lt;BR /&gt; Chip_Clock_SetDivider(CLK_IDIV_B, CLKIN_IDIVA, 15); /* Source DIV_B from DIV_A, [IN 120 MHz; OUT 8 MHz */&lt;BR /&gt; Chip_Clock_SetBaseClock(CLK_BASE_ADCHS, CLKIN_IDIVB, true, false); /* Source ADHCS base clock from DIV_B */&lt;BR /&gt; Chip_Clock_EnableOpts(CLK_ADCHS, true, true, 1); /* Enable the clock */&lt;/P&gt;&lt;P&gt;/* Initialize HSADC */&lt;BR /&gt; Chip_HSADC_Init(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Setup FIFO trip points for interrupt/DMA to 8 samples, no packing */&lt;BR /&gt; Chip_HSADC_SetupFIFO(LPC_ADCHS, 8, false);&lt;/P&gt;&lt;P&gt;/* Software trigger only, 0x90 recovery clocks, add channel IF to FIFO entry */&lt;BR /&gt; Chip_HSADC_ConfigureTrigger(LPC_ADCHS, HSADC_CONFIG_TRIGGER_SW,&lt;BR /&gt; HSADC_CONFIG_TRIGGER_RISEEXT, HSADC_CONFIG_TRIGGER_NOEXTSYNC,&lt;BR /&gt; HSADC_CHANNEL_ID_EN_ADD, 0x90);&lt;/P&gt;&lt;P&gt;/* Select both positive and negative DC biasing for input 3 */&lt;BR /&gt; //Chip_HSADC_SetACDCBias(LPC_ADCHS, 3, HSADC_CHANNEL_DCBIAS, HSADC_CHANNEL_DCBIAS);&lt;BR /&gt; Chip_HSADC_SetACDCBias(LPC_ADCHS, 0, HSADC_CHANNEL_DCBIAS, HSADC_CHANNEL_NODCBIAS);&lt;/P&gt;&lt;P&gt;/* Set low A threshold to 10% and high A threshold to 90% */&lt;BR /&gt; Chip_HSADC_SetThrLowValue(LPC_ADCHS, 0, ((HSADC_MAX_SAMPLEVAL * 1) / 10));&lt;BR /&gt; Chip_HSADC_SetThrHighValue(LPC_ADCHS, 0, ((HSADC_MAX_SAMPLEVAL * 9) / 10));&lt;/P&gt;&lt;P&gt;/* Set low B threshold to 40% and high B threshold to 60% */&lt;BR /&gt; Chip_HSADC_SetThrLowValue(LPC_ADCHS, 1, ((HSADC_MAX_SAMPLEVAL * 4) / 10));&lt;BR /&gt; Chip_HSADC_SetThrHighValue(LPC_ADCHS, 1, ((HSADC_MAX_SAMPLEVAL * 6) / 10));&lt;/P&gt;&lt;P&gt;/* Setup data format for 2's complement and update clock settings. This function&lt;BR /&gt; should be called whenever a clock change is made to the HSADC */&lt;BR /&gt; Chip_HSADC_SetPowerSpeed(LPC_ADCHS, false);&lt;/P&gt;&lt;P&gt;/* Enable HSADC power */&lt;BR /&gt; Chip_HSADC_EnablePower(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Setup HSADC table 0 descriptors */&lt;BR /&gt; /* Descriptor entries are mapped as follows */&lt;BR /&gt; /* 0-1 : mapped to input 0, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 0, (HSADC_DESC_CH(0) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) | HSADC_DESC_THRESH_NONE |&lt;BR /&gt; HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 1, (HSADC_DESC_CH(0) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 2-3 : mapped to input 1, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 2, (HSADC_DESC_CH(1) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 3, (HSADC_DESC_CH(1) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_A | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 4-5 : mapped to input 2, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 4, (HSADC_DESC_CH(2) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 5, (HSADC_DESC_CH(2) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 6-7 : mapped to input 3, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 6, (HSADC_DESC_CH(3) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 7, (HSADC_DESC_CH(3) |&lt;BR /&gt; HSADC_DESC_BRANCH_FIRST | HSADC_DESC_INT |&lt;BR /&gt; HSADC_DESC_MATCH(1) | HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;/* Setup HSADC interrupts on group 0 - FIFO trip (full), FIFO overrun&lt;BR /&gt; error, and descriptor statuses */&lt;BR /&gt; Chip_HSADC_EnableInts(LPC_ADCHS, 0, (HSADC_INT0_FIFO_FULL));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* Init USB API structure */&lt;BR /&gt; g_pUsbApi = (const USBD_API_T *) LPC_ROM_API-&amp;gt;usbdApiBase;&lt;/P&gt;&lt;P&gt;/* initialize call back structures */&lt;BR /&gt; memset((void *) &amp;amp;usb_param, 0, sizeof(USBD_API_INIT_PARAM_T));&lt;BR /&gt; usb_param.usb_reg_base = LPC_USB_BASE;&lt;BR /&gt; usb_param.max_num_ep = 4;&lt;BR /&gt; usb_param.mem_base = USB_STACK_MEM_BASE;&lt;BR /&gt; usb_param.mem_size = USB_STACK_MEM_SIZE;&lt;/P&gt;&lt;P&gt;/* Set the USB descriptors */&lt;BR /&gt; desc.device_desc = (uint8_t *) USB_DeviceDescriptor;&lt;BR /&gt; desc.string_desc = (uint8_t *) USB_StringDescriptor;&lt;BR /&gt;#ifdef USE_USB0&lt;BR /&gt; desc.high_speed_desc = USB_HsConfigDescriptor;&lt;BR /&gt; desc.full_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.device_qualifier = (uint8_t *) USB_DeviceQualifier;&lt;BR /&gt;#else&lt;BR /&gt; /* Note, to pass USBCV test full-speed only devices should have both&lt;BR /&gt; * descriptor arrays point to same location and device_qualifier set&lt;BR /&gt; * to 0.&lt;BR /&gt; */&lt;BR /&gt; desc.high_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.full_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.device_qualifier = 0;&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* USB Initialization */&lt;BR /&gt; ret = USBD_API-&amp;gt;hw-&amp;gt;Init(&amp;amp;g_hUsb, &amp;amp;desc, &amp;amp;usb_param);&lt;BR /&gt; if (ret == LPC_OK) {&lt;/P&gt;&lt;P&gt;/* WORKAROUND for artf45032 ROM driver BUG:&lt;BR /&gt; Due to a race condition there is the chance that a second NAK event will&lt;BR /&gt; occur before the default endpoint0 handler has completed its preparation&lt;BR /&gt; of the DMA engine for the first NAK event. This can cause certain fields&lt;BR /&gt; in the DMA descriptors to be in an invalid state when the USB controller&lt;BR /&gt; reads them, thereby causing a hang.&lt;BR /&gt; */&lt;BR /&gt; pCtrl = (USB_CORE_CTRL_T *) g_hUsb; /* convert the handle to control structure */&lt;BR /&gt; g_Ep0BaseHdlr = pCtrl-&amp;gt;ep_event_hdlr[0];/* retrieve the default EP0_OUT handler */&lt;BR /&gt; pCtrl-&amp;gt;ep_event_hdlr[0] = EP0_patch;/* set our patch routine as EP0_OUT handler */&lt;/P&gt;&lt;P&gt;/* Init VCOM interface */&lt;BR /&gt; ret = vcom_init(g_hUsb, &amp;amp;desc, &amp;amp;usb_param);&lt;BR /&gt; if (ret == LPC_OK) {&lt;BR /&gt; /* enable USB interrupts */&lt;BR /&gt; NVIC_EnableIRQ(LPC_USB_IRQ);&lt;BR /&gt; /* now connect */&lt;BR /&gt; USBD_API-&amp;gt;hw-&amp;gt;Connect(g_hUsb, 1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Initial all GPIO */&lt;BR /&gt; Chip_GPIO_Init(LPC_GPIO_PORT);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 3, 1);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 1);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 3);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 12);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* Set them low for mux_state = 0 */&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 3, 1);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 1);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 3);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 12);&lt;/P&gt;&lt;P&gt;/* Enable HSADC interrupts in NVIC */&lt;BR /&gt; NVIC_EnableIRQ(ADCHS_IRQn);&lt;/P&gt;&lt;P&gt;/* Update descriptor tables - needed after updating any descriptors */&lt;BR /&gt; Chip_HSADC_UpdateDescTable(LPC_ADCHS, 0);&lt;/P&gt;&lt;P&gt;/* Chose active Descriptor */&lt;BR /&gt; Chip_HSADC_SetActiveDescriptor(LPC_ADCHS, 0, 0);&lt;/P&gt;&lt;P&gt;/* Initial Descriptor with Software-Trigger */&lt;BR /&gt; Chip_HSADC_SWTrigger(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Sleep while waiting for conversions */&lt;BR /&gt; while (1) {&lt;BR /&gt; __WFI();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and comments.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Dec 2016 13:18:07 GMT</pubDate>
    <dc:creator>richardmarquard</dc:creator>
    <dc:date>2016-12-19T13:18:07Z</dc:date>
    <item>
      <title>LPC4370 ADC gives incorrect data</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-ADC-gives-incorrect-data/m-p/623233#M24473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;we are using LPC4370 with LPCexpresso&amp;nbsp;for high speed meassurement. The microcontroller gives control signals to 4 analog multiplexer (8:1). Simultaneously, the same microcontroller is used for reading the ouput signals of the four multiplexer. The 4 output signals is given to ADC GPIOS. These input GPIOS have the same initialisation. However, just 3 of them works. The last GPIO gives wrong data. Do you have same experiences, any suggestions or tips ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The initialisation code is attached below: &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; USBD_API_INIT_PARAM_T usb_param;&lt;BR /&gt; USB_CORE_DESCS_T desc;&lt;BR /&gt; ErrorCode_t ret = LPC_OK;&lt;BR /&gt; USB_CORE_CTRL_T *pCtrl;&lt;/P&gt;&lt;P&gt;/* Initialize board and chip */&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;/P&gt;&lt;P&gt;/* enable clocks and pinmux */&lt;BR /&gt; USB_init_pin_clk();&lt;/P&gt;&lt;P&gt;/* Setting up the HSADC clock is more complex than other peripherals.&lt;BR /&gt; The HSADC clock is driven directly from the CGU/CCU and has limited&lt;BR /&gt; source and divider options. Because the HSADC clocking is entirely&lt;BR /&gt; handled outside the HSADC peripheral, example code for setting up&lt;BR /&gt; the CGU/CCU to get a rough HSADC clock rate is included in this&lt;BR /&gt; example. */&lt;/P&gt;&lt;P&gt;Chip_USB0_Init(); /* Initialize the USB0 PLL to 480 MHz */&lt;BR /&gt; Chip_Clock_SetDivider(CLK_IDIV_A, CLKIN_USBPLL, 4); /* Source DIV_A from USB0PLL, and set divider to 2 (Max div value supported is 4) [IN 480 MHz; OUT 120 MHz */&lt;BR /&gt; Chip_Clock_SetDivider(CLK_IDIV_B, CLKIN_IDIVA, 15); /* Source DIV_B from DIV_A, [IN 120 MHz; OUT 8 MHz */&lt;BR /&gt; Chip_Clock_SetBaseClock(CLK_BASE_ADCHS, CLKIN_IDIVB, true, false); /* Source ADHCS base clock from DIV_B */&lt;BR /&gt; Chip_Clock_EnableOpts(CLK_ADCHS, true, true, 1); /* Enable the clock */&lt;/P&gt;&lt;P&gt;/* Initialize HSADC */&lt;BR /&gt; Chip_HSADC_Init(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Setup FIFO trip points for interrupt/DMA to 8 samples, no packing */&lt;BR /&gt; Chip_HSADC_SetupFIFO(LPC_ADCHS, 8, false);&lt;/P&gt;&lt;P&gt;/* Software trigger only, 0x90 recovery clocks, add channel IF to FIFO entry */&lt;BR /&gt; Chip_HSADC_ConfigureTrigger(LPC_ADCHS, HSADC_CONFIG_TRIGGER_SW,&lt;BR /&gt; HSADC_CONFIG_TRIGGER_RISEEXT, HSADC_CONFIG_TRIGGER_NOEXTSYNC,&lt;BR /&gt; HSADC_CHANNEL_ID_EN_ADD, 0x90);&lt;/P&gt;&lt;P&gt;/* Select both positive and negative DC biasing for input 3 */&lt;BR /&gt; //Chip_HSADC_SetACDCBias(LPC_ADCHS, 3, HSADC_CHANNEL_DCBIAS, HSADC_CHANNEL_DCBIAS);&lt;BR /&gt; Chip_HSADC_SetACDCBias(LPC_ADCHS, 0, HSADC_CHANNEL_DCBIAS, HSADC_CHANNEL_NODCBIAS);&lt;/P&gt;&lt;P&gt;/* Set low A threshold to 10% and high A threshold to 90% */&lt;BR /&gt; Chip_HSADC_SetThrLowValue(LPC_ADCHS, 0, ((HSADC_MAX_SAMPLEVAL * 1) / 10));&lt;BR /&gt; Chip_HSADC_SetThrHighValue(LPC_ADCHS, 0, ((HSADC_MAX_SAMPLEVAL * 9) / 10));&lt;/P&gt;&lt;P&gt;/* Set low B threshold to 40% and high B threshold to 60% */&lt;BR /&gt; Chip_HSADC_SetThrLowValue(LPC_ADCHS, 1, ((HSADC_MAX_SAMPLEVAL * 4) / 10));&lt;BR /&gt; Chip_HSADC_SetThrHighValue(LPC_ADCHS, 1, ((HSADC_MAX_SAMPLEVAL * 6) / 10));&lt;/P&gt;&lt;P&gt;/* Setup data format for 2's complement and update clock settings. This function&lt;BR /&gt; should be called whenever a clock change is made to the HSADC */&lt;BR /&gt; Chip_HSADC_SetPowerSpeed(LPC_ADCHS, false);&lt;/P&gt;&lt;P&gt;/* Enable HSADC power */&lt;BR /&gt; Chip_HSADC_EnablePower(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Setup HSADC table 0 descriptors */&lt;BR /&gt; /* Descriptor entries are mapped as follows */&lt;BR /&gt; /* 0-1 : mapped to input 0, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 0, (HSADC_DESC_CH(0) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) | HSADC_DESC_THRESH_NONE |&lt;BR /&gt; HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 1, (HSADC_DESC_CH(0) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 2-3 : mapped to input 1, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 2, (HSADC_DESC_CH(1) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 3, (HSADC_DESC_CH(1) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_A | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 4-5 : mapped to input 2, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 4, (HSADC_DESC_CH(2) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 5, (HSADC_DESC_CH(2) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;BR /&gt; /* 6-7 : mapped to input 3, branch to next descriptor after sample, match time&lt;BR /&gt; is 1 test against no threshold */&lt;BR /&gt; Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 6, (HSADC_DESC_CH(3) |&lt;BR /&gt; HSADC_DESC_BRANCH_NEXT | HSADC_DESC_MATCH(1) |&lt;BR /&gt; HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;Chip_HSADC_SetupDescEntry(LPC_ADCHS, 0, 7, (HSADC_DESC_CH(3) |&lt;BR /&gt; HSADC_DESC_BRANCH_FIRST | HSADC_DESC_INT |&lt;BR /&gt; HSADC_DESC_MATCH(1) | HSADC_DESC_THRESH_NONE | HSADC_DESC_RESET_TIMER));&lt;/P&gt;&lt;P&gt;/* Setup HSADC interrupts on group 0 - FIFO trip (full), FIFO overrun&lt;BR /&gt; error, and descriptor statuses */&lt;BR /&gt; Chip_HSADC_EnableInts(LPC_ADCHS, 0, (HSADC_INT0_FIFO_FULL));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* Init USB API structure */&lt;BR /&gt; g_pUsbApi = (const USBD_API_T *) LPC_ROM_API-&amp;gt;usbdApiBase;&lt;/P&gt;&lt;P&gt;/* initialize call back structures */&lt;BR /&gt; memset((void *) &amp;amp;usb_param, 0, sizeof(USBD_API_INIT_PARAM_T));&lt;BR /&gt; usb_param.usb_reg_base = LPC_USB_BASE;&lt;BR /&gt; usb_param.max_num_ep = 4;&lt;BR /&gt; usb_param.mem_base = USB_STACK_MEM_BASE;&lt;BR /&gt; usb_param.mem_size = USB_STACK_MEM_SIZE;&lt;/P&gt;&lt;P&gt;/* Set the USB descriptors */&lt;BR /&gt; desc.device_desc = (uint8_t *) USB_DeviceDescriptor;&lt;BR /&gt; desc.string_desc = (uint8_t *) USB_StringDescriptor;&lt;BR /&gt;#ifdef USE_USB0&lt;BR /&gt; desc.high_speed_desc = USB_HsConfigDescriptor;&lt;BR /&gt; desc.full_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.device_qualifier = (uint8_t *) USB_DeviceQualifier;&lt;BR /&gt;#else&lt;BR /&gt; /* Note, to pass USBCV test full-speed only devices should have both&lt;BR /&gt; * descriptor arrays point to same location and device_qualifier set&lt;BR /&gt; * to 0.&lt;BR /&gt; */&lt;BR /&gt; desc.high_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.full_speed_desc = USB_FsConfigDescriptor;&lt;BR /&gt; desc.device_qualifier = 0;&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/* USB Initialization */&lt;BR /&gt; ret = USBD_API-&amp;gt;hw-&amp;gt;Init(&amp;amp;g_hUsb, &amp;amp;desc, &amp;amp;usb_param);&lt;BR /&gt; if (ret == LPC_OK) {&lt;/P&gt;&lt;P&gt;/* WORKAROUND for artf45032 ROM driver BUG:&lt;BR /&gt; Due to a race condition there is the chance that a second NAK event will&lt;BR /&gt; occur before the default endpoint0 handler has completed its preparation&lt;BR /&gt; of the DMA engine for the first NAK event. This can cause certain fields&lt;BR /&gt; in the DMA descriptors to be in an invalid state when the USB controller&lt;BR /&gt; reads them, thereby causing a hang.&lt;BR /&gt; */&lt;BR /&gt; pCtrl = (USB_CORE_CTRL_T *) g_hUsb; /* convert the handle to control structure */&lt;BR /&gt; g_Ep0BaseHdlr = pCtrl-&amp;gt;ep_event_hdlr[0];/* retrieve the default EP0_OUT handler */&lt;BR /&gt; pCtrl-&amp;gt;ep_event_hdlr[0] = EP0_patch;/* set our patch routine as EP0_OUT handler */&lt;/P&gt;&lt;P&gt;/* Init VCOM interface */&lt;BR /&gt; ret = vcom_init(g_hUsb, &amp;amp;desc, &amp;amp;usb_param);&lt;BR /&gt; if (ret == LPC_OK) {&lt;BR /&gt; /* enable USB interrupts */&lt;BR /&gt; NVIC_EnableIRQ(LPC_USB_IRQ);&lt;BR /&gt; /* now connect */&lt;BR /&gt; USBD_API-&amp;gt;hw-&amp;gt;Connect(g_hUsb, 1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Initial all GPIO */&lt;BR /&gt; Chip_GPIO_Init(LPC_GPIO_PORT);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 3, 1);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 1);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 3);&lt;BR /&gt; Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 12);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* Set them low for mux_state = 0 */&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 3, 1);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 1);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 3);&lt;BR /&gt; Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 1, 12);&lt;/P&gt;&lt;P&gt;/* Enable HSADC interrupts in NVIC */&lt;BR /&gt; NVIC_EnableIRQ(ADCHS_IRQn);&lt;/P&gt;&lt;P&gt;/* Update descriptor tables - needed after updating any descriptors */&lt;BR /&gt; Chip_HSADC_UpdateDescTable(LPC_ADCHS, 0);&lt;/P&gt;&lt;P&gt;/* Chose active Descriptor */&lt;BR /&gt; Chip_HSADC_SetActiveDescriptor(LPC_ADCHS, 0, 0);&lt;/P&gt;&lt;P&gt;/* Initial Descriptor with Software-Trigger */&lt;BR /&gt; Chip_HSADC_SWTrigger(LPC_ADCHS);&lt;/P&gt;&lt;P&gt;/* Sleep while waiting for conversions */&lt;BR /&gt; while (1) {&lt;BR /&gt; __WFI();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help and comments.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Dec 2016 13:18:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4370-ADC-gives-incorrect-data/m-p/623233#M24473</guid>
      <dc:creator>richardmarquard</dc:creator>
      <dc:date>2016-12-19T13:18:07Z</dc:date>
    </item>
  </channel>
</rss>

