<?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 Re: i.MX8 M4 Multiple Analogue Inputs in one Interrupt in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1685795#M209056</link>
    <description>&lt;P&gt;Dear Sanket Parekh,&lt;/P&gt;&lt;P&gt;Thank you very much for the quick response.&lt;/P&gt;&lt;P&gt;It worked perfectly and exactly as intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Cillex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 13:06:44 GMT</pubDate>
    <dc:creator>Cillex</dc:creator>
    <dc:date>2023-07-11T13:06:44Z</dc:date>
    <item>
      <title>i.MX8 M4 Multiple Analogue Inputs in one Interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1684662#M208944</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am currently trying to read two different analogue inputs at the same time using the M4 of a Toradex imx8dx system.&lt;/P&gt;&lt;P&gt;Right now i have one ADC channel in use reading on an interrupt.&lt;/P&gt;&lt;P&gt;The ideal solution would be to use the same interrupt to read a second channel (as far as I understand it the ADC chip reads all inputs at the same time, therefore they should already be ready at the same time).&lt;/P&gt;&lt;P&gt;Can someone help me to set the settings correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the useful bits of my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* ADC IN 1 PIN: SODIMM 4 -&amp;gt; ADMA_ADC0_IN4&lt;BR /&gt;* ADC IN 2 PIN: SODIMM 2 -&amp;gt; ADMA_ADC0_IN5&lt;BR /&gt;*/&lt;BR /&gt;#define SENSOR_LPADC_BASE ADMA__ADC0&lt;BR /&gt;#define SENSOR_1_LPADC_USER_CHANNEL 4U&lt;BR /&gt;#define SENSOR_1_LPADC_USER_CMDID 1U&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define SENSOR_2_LPADC_USER_CHANNEL 5U&lt;BR /&gt;#define SENSOR_2_LPADC_USER_CMDID 2U&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define SENSOR_LPADC_IRQn ADMA_ADC0_INT_IRQn&lt;BR /&gt;#define SENSOR_LPADC_IRQ_HANDLER_FUNC ADMA_ADC0_INT_IRQHandler&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* ADC VARs&lt;BR /&gt;*/&lt;BR /&gt;volatile bool g_LpadcConversionCompletedFlag = false;&lt;BR /&gt;volatile uint32_t g_LpadcInterruptCounter = 0U;&lt;BR /&gt;lpadc_conv_result_t g_LpadcResultConfigStruct;&lt;BR /&gt;#if (defined(DEMO_LPADC_USE_HIGH_RESOLUTION) &amp;amp;&amp;amp; DEMO_LPADC_USE_HIGH_RESOLUTION)&lt;BR /&gt;&amp;nbsp; const uint32_t g_LpadcFullRange = 65536U;&lt;BR /&gt;&amp;nbsp; const uint32_t g_LpadcResultShift = 0U;&lt;BR /&gt;#else&lt;BR /&gt;&amp;nbsp; const uint32_t g_LpadcFullRange = 4096U;&lt;BR /&gt;&amp;nbsp; const uint32_t g_LpadcResultShift = 3U;&lt;BR /&gt;#endif /* DEMO_LPADC_USE_HIGH_RESOLUTION */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* IRQ_HANDLER OF ADC&lt;BR /&gt;*&lt;BR /&gt;*/&lt;BR /&gt;void SENSOR_LPADC_IRQ_HANDLER_FUNC(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; g_LpadcInterruptCounter++;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (LPADC_GetConvResult(SENSOR_LPADC_BASE, &amp;amp;g_LpadcResultConfigStruct))&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; //read value and write to picture&lt;BR /&gt;&amp;nbsp; &amp;nbsp; picture_1[irq_count-1] = ((g_LpadcResultConfigStruct.convValue) &amp;gt;&amp;gt; g_LpadcResultShift);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; //read second value&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; picture_2[irq_count-1] = 0; //get second value from ADC channel 5U&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; SDK_ISR_EXIT_BARRIER;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;*!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;* @brief Main function&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;*/&lt;/DIV&gt;&lt;DIV&gt;int main(void)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; uint32_t time = timestamp_simple;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; sc_ipc_t ipc;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; ipc = BOARD_InitRpc();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; BOARD_InitPins(ipc);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; BOARD_BootClockRUN();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; BOARD_InitMemory();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; BOARD_InitDebugConsole();&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/*&lt;/DIV&gt;&lt;DIV&gt;* ADC INIT&lt;/DIV&gt;&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;LEVEL_SENSOR_1&lt;/DIV&gt;&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;LEVEL_SENSOR_2&lt;/DIV&gt;&lt;DIV&gt;*/&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; lpadc_config_t mLpadcConfigStruct;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; lpadc_conv_trigger_config_t mLpadcTriggerConfigStruct;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; lpadc_conv_command_config_t mLpadcCommandConfigStruct;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if (sc_pm_set_resource_power_mode(ipc, SC_R_ADC_0, SC_PM_PW_MODE_ON) != SC_ERR_NONE)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRINTF("Error: Failed to power on ADC\r\n");&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; IRQSTEER_EnableInterrupt(IRQSTEER, ADMA_ADC0_INT_IRQn);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_GetDefaultConfig(&amp;amp;mLpadcConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; mLpadcConfigStruct.enableAnalogPreliminary = true;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_Init(SENSOR_LPADC_BASE, &amp;amp;mLpadcConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// CHECK FOR SECOND CHANNEL&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_GetDefaultConvCommandConfig(&amp;amp;mLpadcCommandConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; mLpadcCommandConfigStruct.channelNumber = SENSOR_1_LPADC_USER_CHANNEL;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; //mLpadcCommandConfigStruct.chainedNextCommandNumber = SENSOR_2_LPADC_USER_CMDID; //ADDED FOR 2.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_SetConvCommandConfig(SENSOR_LPADC_BASE, SENSOR_1_LPADC_USER_CMDID, &amp;amp;mLpadcCommandConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_GetDefaultConvCommandConfig(&amp;amp;mLpadcCommandConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_GetDefaultConvTriggerConfig(&amp;amp;mLpadcTriggerConfigStruct);&lt;/DIV&gt;&lt;DIV&gt;// CHECK FOR SECOND CHANNEL&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; //1. CHAN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; mLpadcTriggerConfigStruct.targetCommandId&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= SENSOR_1_LPADC_USER_CMDID;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; //2. CHAN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; //mLpadcTriggerConfigStruct.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; mLpadcTriggerConfigStruct.enableHardwareTrigger = false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_SetConvTriggerConfig(SENSOR_LPADC_BASE, 0U, &amp;amp;mLpadcTriggerConfigStruct);&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPADC_EnableInterrupts(SENSOR_LPADC_BASE, kLPADC_FIFOWatermarkInterruptEnable);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; EnableIRQ(SENSOR_LPADC_IRQn);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/*&lt;/DIV&gt;&lt;DIV&gt;* MAIN LOOP&lt;/DIV&gt;&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;leave empty when finished&lt;/DIV&gt;&lt;DIV&gt;*&amp;nbsp; &amp;nbsp; &amp;nbsp;only used for debugging&lt;/DIV&gt;&lt;DIV&gt;*/&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; while (true)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; {&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SDK_DelayAtLeastUs(1000000, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; LPADC_DoSoftwareTrigger(SENSOR_LPADC_BASE, 1U); //get ADC values&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:39:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1684662#M208944</guid>
      <dc:creator>Cillex</dc:creator>
      <dc:date>2023-07-10T08:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 M4 Multiple Analogue Inputs in one Interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1685740#M209047</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/219306"&gt;@Cillex&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I hope you are doing well.&lt;/P&gt;
&lt;P&gt;One can use separate command for multiple ADC channels.&lt;/P&gt;
&lt;P&gt;Please refer to example given at boards/mekmimx8qm/driver_examples/lpadc/interrupt/cm4_core0 in SDK&lt;/P&gt;
&lt;P&gt;e.g.&lt;/P&gt;
&lt;P&gt;LPADC_GetDefaultConvCommandConfig(&amp;amp;mLpadcCommandConfigStruct1);&lt;BR /&gt;mLpadcCommandConfigStruct1.channelNumber = DEMO_LPADC_USER_CHANNEL1;&lt;BR /&gt;mLpadcCommandConfigStruct1.conversionResolutionMode = kLPADC_ConversionResolutionHigh;&lt;BR /&gt;LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID1, &amp;amp;mLpadcCommandConfigStruct1);&lt;/P&gt;
&lt;P&gt;LPADC_GetDefaultConvCommandConfig(&amp;amp;mLpadcCommandConfigStruct2);&lt;BR /&gt;mLpadcCommandConfigStruct2.channelNumber = DEMO_LPADC_USER_CHANNEL2;&lt;BR /&gt;mLpadcCommandConfigStruct2.conversionResolutionMode = kLPADC_ConversionResolutionHigh;&lt;BR /&gt;LPADC_SetConvCommandConfig(DEMO_LPADC_BASE, DEMO_LPADC_USER_CMDID2, &amp;amp;mLpadcCommandConfigStruct2);&lt;/P&gt;
&lt;P&gt;/* Set trigger configuration. */&lt;/P&gt;
&lt;P&gt;LPADC_GetDefaultConvTriggerConfig(&amp;amp;mLpadcTriggerConfigStruct1);&lt;BR /&gt;mLpadcTriggerConfigStruct1.targetCommandId = DEMO_LPADC_USER_CMDID1; &lt;BR /&gt;mLpadcTriggerConfigStruct1.enableHardwareTrigger = false;&lt;BR /&gt;LPADC_SetConvTriggerConfig(DEMO_LPADC_BASE, 0U, &amp;amp;mLpadcTriggerConfigStruct1); /* Configurate the trigger0. */&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;LPADC_GetDefaultConvTriggerConfig(&amp;amp;mLpadcTriggerConfigStruct2);&lt;BR /&gt;mLpadcTriggerConfigStruct2.targetCommandId = DEMO_LPADC_USER_CMDID2; &lt;BR /&gt;mLpadcTriggerConfigStruct2.enableHardwareTrigger = false;&lt;BR /&gt;LPADC_SetConvTriggerConfig(DEMO_LPADC_BASE, 1U, &amp;amp;mLpadcTriggerConfigStruct2);&lt;/P&gt;
&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;Then one can use LPADC_DoSoftwareTrigger to trigger software.&lt;/P&gt;
&lt;P&gt;LPADC_DoSoftwareTrigger(DEMO_LPADC_BASE, 1U&amp;lt;&amp;lt;0); // trigger 0&lt;/P&gt;
&lt;P&gt;LPADC_DoSoftwareTrigger(DEMO_LPADC_BASE, 1U&amp;lt;&amp;lt;1)); // trigger 1.&lt;/P&gt;
&lt;P&gt;One can determine which channel reading are available using &lt;A href="https://mcuxpresso.nxp.com/api_doc/dev/1581/group__lpadc.html#structlpadc__conv__result__t" target="_self"&gt;g_LpadcResultConfigStruct&lt;/A&gt; in ISR.&lt;/P&gt;
&lt;P&gt;g_LpadcResultConfigStruct.commandIdSource // One can determine the channel using command ID.&lt;/P&gt;
&lt;P&gt;Please refer to 17.2 Analog-to-Digital Converter (ADC) in RM for more information.&lt;/P&gt;
&lt;P&gt;I hope it helps!&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;Sanket Parekh&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 11:19:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1685740#M209047</guid>
      <dc:creator>Sanket_Parekh</dc:creator>
      <dc:date>2023-07-11T11:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: i.MX8 M4 Multiple Analogue Inputs in one Interrupt</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1685795#M209056</link>
      <description>&lt;P&gt;Dear Sanket Parekh,&lt;/P&gt;&lt;P&gt;Thank you very much for the quick response.&lt;/P&gt;&lt;P&gt;It worked perfectly and exactly as intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Cillex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 13:06:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/i-MX8-M4-Multiple-Analogue-Inputs-in-one-Interrupt/m-p/1685795#M209056</guid>
      <dc:creator>Cillex</dc:creator>
      <dc:date>2023-07-11T13:06:44Z</dc:date>
    </item>
  </channel>
</rss>

