<?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のトピックlpcXpresso55s16 adc support</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658370#M52753</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;Please help me to provide the configuration steps and sample codes of adc read for lpcXpresso55s16 which has to be work with zephyr 3.3.99&lt;/P&gt;</description>
    <pubDate>Fri, 26 May 2023 11:17:38 GMT</pubDate>
    <dc:creator>ArjunDinesh</dc:creator>
    <dc:date>2023-05-26T11:17:38Z</dc:date>
    <item>
      <title>lpcXpresso55s16 adc support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658370#M52753</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;Please help me to provide the configuration steps and sample codes of adc read for lpcXpresso55s16 which has to be work with zephyr 3.3.99&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 11:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658370#M52753</guid>
      <dc:creator>ArjunDinesh</dc:creator>
      <dc:date>2023-05-26T11:17:38Z</dc:date>
    </item>
    <item>
      <title>Hi DerekSnell,  Thanks for your immediate response.  I referred the fRe: lpcXpresso55s16 adc support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658738#M52761</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I referred the following tutorial and the ADC reference of Zephyr :&lt;/P&gt;&lt;P&gt;&lt;A title="Zephyr 101 - ADC + Thread Control" href="https://www.youtube.com/watch?v=Y8FaEcAp_kY" target="_self"&gt;https://www.youtube.com/watch?v=Y8FaEcAp_kY&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="Analog-to-Digital Converter (ADC)" href="https://docs.zephyrproject.org/latest/samples/drivers/adc/README.html" target="_self"&gt;https://docs.zephyrproject.org/latest/samples/drivers/adc/README.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made changes to the LPCXpresso55s16 board file by referring the board file of LPCXpresso55s69:&lt;/P&gt;&lt;P&gt;1) Added pinmux_lpadc0 configuration to lpcxpresso55s16-pinctrl.dtsi file&lt;BR /&gt;pinmux_lpadc0: pinmux_lpadc0 {&lt;BR /&gt;group0 {&lt;BR /&gt;pinmux = &amp;lt;ADC0_CH0_PIO0_23&amp;gt;,&lt;BR /&gt;&amp;lt;ADC0_CH8_PIO0_16&amp;gt;,&lt;BR /&gt;&amp;lt;ADC0_CH4_PIO1_8&amp;gt;,&lt;BR /&gt;&amp;lt;ADC0_CH12_PIO1_9&amp;gt;;&lt;BR /&gt;slew-rate = "standard";&lt;BR /&gt;nxp,analog-mode;&lt;BR /&gt;};&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;2) Enabled ADC through adding the below code to lpcxpresso55s16.dts file&lt;BR /&gt;&amp;amp;adc0 {&lt;BR /&gt;status = "okay";&lt;BR /&gt;pinctrl-0 = &amp;lt;&amp;amp;pinmux_lpadc0&amp;gt;;&lt;BR /&gt;pinctrl-names = "default";&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;3) Added 'adc' under supported section of the lpcxpresso55s16.yaml file&lt;BR /&gt;identifier: lpcxpresso55s16&lt;BR /&gt;name: NXP LPCXpresso55S16&lt;BR /&gt;type: mcu&lt;BR /&gt;arch: arm&lt;BR /&gt;ram: 96&lt;BR /&gt;flash: 256&lt;BR /&gt;toolchain:&lt;BR /&gt;- zephyr&lt;BR /&gt;- gnuarmemb&lt;BR /&gt;- xtools&lt;BR /&gt;supported:&lt;BR /&gt;- adc&lt;BR /&gt;- arduino_gpio&lt;BR /&gt;- arduino_i2c&lt;BR /&gt;- arduino_spi&lt;BR /&gt;- can&lt;BR /&gt;- gpio&lt;BR /&gt;- i2c&lt;BR /&gt;- spi&lt;BR /&gt;- usb_device&lt;/P&gt;&lt;P&gt;4) Added adc0 under the aliases field of the lpcxpresso55s16_common.dtsi file&lt;BR /&gt;aliases{&lt;BR /&gt;led0 = &amp;amp;red_led;&lt;BR /&gt;led1 = &amp;amp;green_led;&lt;BR /&gt;led2 = &amp;amp;blue_led;&lt;BR /&gt;sw0 = &amp;amp;btn_wk;&lt;BR /&gt;sw1 = &amp;amp;btn_usr;&lt;BR /&gt;sw2 = &amp;amp;btn_isp;&lt;BR /&gt;adcctrl = &amp;amp;adc0;&lt;BR /&gt;usart-0 = &amp;amp;flexcomm0;&lt;BR /&gt;magn0 = &amp;amp;fxos8700;&lt;BR /&gt;accel0 = &amp;amp;fxos8700;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;I used the below code to read the adc samples from LPCXpresso55s16 through PIO0_23/ADC0_0 (12th pin - LPC55S16JBD64)&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;zephyr.h&amp;gt;&lt;BR /&gt;#include &amp;lt;device.h&amp;gt;&lt;BR /&gt;#include &amp;lt;drivers/adc.h&amp;gt;&lt;BR /&gt;#include "logging/osal_log.h"&lt;BR /&gt;#include &amp;lt;can_com.h&amp;gt;&lt;BR /&gt;#include "can/osal_can.h"&lt;/P&gt;&lt;P&gt;#define ADC_DEVICE_NAME "DT_LABEL(DT_ALIAS(adcctrl))"&lt;BR /&gt;OSAL_LOG_MODULE_REGISTER(com_data_handler);&lt;/P&gt;&lt;P&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;enum adc_gain {&lt;BR /&gt;ADC_GAIN_1_6,&lt;BR /&gt;ADC_GAIN_1_5,&lt;BR /&gt;ADC_GAIN_1_4,&lt;BR /&gt;ADC_GAIN_1_3,&lt;BR /&gt;ADC_GAIN_1_2,&lt;BR /&gt;ADC_GAIN_2_3,&lt;BR /&gt;ADC_GAIN_1,&lt;BR /&gt;ADC_GAIN_2,&lt;BR /&gt;ADC_GAIN_3,&lt;BR /&gt;ADC_GAIN_4,&lt;BR /&gt;ADC_GAIN_8,&lt;BR /&gt;ADC_GAIN_16,&lt;BR /&gt;ADC_GAIN_32,&lt;BR /&gt;ADC_GAIN_64,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;enum adc_reference {&lt;BR /&gt;ADC_REF_VDD_1,&lt;BR /&gt;ADC_REF_VDD_1_2,&lt;BR /&gt;ADC_REF_VDD_1_3,&lt;BR /&gt;ADC_REF_VDD_1_4,&lt;BR /&gt;ADC_REF_INTERNAL,&lt;BR /&gt;ADC_REF_EXTERNAL0,&lt;BR /&gt;ADC_REF_EXTERNAL1,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;enum adc_input_positive {&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN0,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN1,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN2,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN3,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN4,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN5,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN6,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN7,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN8,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN9,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN10,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN11,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN12,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN13,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN14,&lt;BR /&gt;ADC_POSITIVE_INPUT_AIN15,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;struct adc_channel_cfg {&lt;BR /&gt;uint32_t acquisition_time;&lt;BR /&gt;uint8_t channel_id;&lt;BR /&gt;enum adc_input_positive input_positive;&lt;BR /&gt;enum adc_gain gain;&lt;BR /&gt;enum adc_reference reference;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;struct adc_sequence {&lt;BR /&gt;uint16_t *buffer;&lt;BR /&gt;uint16_t buffer_size;&lt;BR /&gt;uint8_t resolution;&lt;BR /&gt;uint8_t channels;&lt;BR /&gt;struct adc_channel_cfg *channels_cfg;&lt;BR /&gt;const struct adc_sequence_options *options;&lt;BR /&gt;uint32_t timeout;&lt;BR /&gt;bool calibrate;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const struct device *adc_dev;&lt;BR /&gt;struct adc_channel_cfg channel_cfg;&lt;BR /&gt;struct adc_sequence sequence;&lt;BR /&gt;uint16_t buffer[4];&lt;/P&gt;&lt;P&gt;adc_dev = device_get_binding(ADC_DEVICE_NAME);&lt;BR /&gt;if (!adc_dev) {&lt;BR /&gt;OSAL_LOG_INF("Failed to get ADC device\n");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;channel_cfg.gain = ADC_GAIN_1_6;&lt;BR /&gt;channel_cfg.reference = ADC_REF_INTERNAL;&lt;BR /&gt;channel_cfg.acquisition_time = ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40);&lt;BR /&gt;channel_cfg.channel_id = 0;&lt;BR /&gt;channel_cfg.input_positive = ADC_POSITIVE_INPUT_AIN0;&lt;/P&gt;&lt;P&gt;sequence.buffer = buffer;&lt;BR /&gt;sequence.buffer_size = sizeof(buffer);&lt;BR /&gt;sequence.resolution = 16;&lt;BR /&gt;sequence.channels = 1;&lt;/P&gt;&lt;P&gt;sequence.options = NULL;&lt;BR /&gt;sequence.timeout = SYS_FOREVER_MS;&lt;BR /&gt;sequence.calibrate = false;&lt;BR /&gt;sequence.channels_cfg = &amp;amp;channel_cfg;&lt;/P&gt;&lt;P&gt;while (1) {&lt;BR /&gt;if (adc_read(adc_dev, &amp;amp;sequence) != 0) {&lt;BR /&gt;OSAL_LOG_INF("ADC read failed\n");&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;OSAL_LOG_INF("ADC value: %u\n", buffer[0]);&lt;/P&gt;&lt;P&gt;k_sleep(K_SECONDS(1));&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am able to build the code without any error. But, after connecting the real LPCXpresso55s16 board and flashed the hex file into the board.&lt;BR /&gt;The output is showing error:&lt;/P&gt;&lt;P&gt;*** Booting Zephyr OS build zephyr-v3.3.0-3441-g3154e03c454a ***&lt;BR /&gt;[00:00:00.005,000] &amp;lt;inf&amp;gt; com_data_handler: Failed to get ADC device&lt;/P&gt;&lt;P&gt;I am not sure where I made mistakes. If there is any possibilities, please guide me to resolve this issue.&lt;BR /&gt;Any suggestions and corrections are greatly appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 May 2023 10:26:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658738#M52761</guid>
      <dc:creator>ArjunDinesh</dc:creator>
      <dc:date>2023-05-28T10:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Hi DerekSnell,  Thanks for your immediate response.  I referred the fRe: lpcXpresso55s16 adc sup</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658779#M52763</link>
      <description>&lt;P&gt;HI&amp;nbsp;ArjunDinesh&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;This is Zephr related question, please create a&amp;nbsp;Discussion&amp;nbsp;to GitHub:&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;A href="https://github.com/zephyrproject-rtos/zephyr/discussions" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/zephyrproject-rtos/zephyr/discussions&lt;/A&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;Thanks,&lt;/P&gt;
&lt;P data-unlink="true"&gt;Jun Zhang&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 01:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1658779#M52763</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2023-05-29T01:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: lpcXpresso55s16 adc support</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1659345#M52781</link>
      <description>&lt;P&gt;Hi Jun Zhang,&lt;/P&gt;&lt;P&gt;I posted the same query in github.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/zephyrproject-rtos/zephyr/discussions/58309" target="_blank"&gt;https://github.com/zephyrproject-rtos/zephyr/discussions/58309&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanking you,&lt;/P&gt;&lt;P&gt;Arjun Dinesh&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 00:39:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpcXpresso55s16-adc-support/m-p/1659345#M52781</guid>
      <dc:creator>ArjunDinesh</dc:creator>
      <dc:date>2023-05-30T00:39:00Z</dc:date>
    </item>
  </channel>
</rss>

