Hello,
I am using NXP Model-Based Design Toolbox for iMXRT117x and have multiple channels to read from. However, using multiple ADC Read blocks results in compile error as multiple lines of the following code are placed in code:
lpadc_conv_result_t mLpadcResultConfigStruct[%<adcParams.commandsNumber>];
const uint32_t g_LpadcResultShift = %<resultShift>;
The Help dialog box and example only demonstrate a single ADC read and that the output is the converted value. How can I do this for multiple ADC channels to read from?
I am using version 1.3.0 of the toolbox.
解決済! 解決策の投稿を見る。
Hello,
I've attached an example that reads from 3 channels as below:
- XBAR0_TRIG.0: Read voltage (COMMAND ID 1) on J9[10]
-XBAR0_TRIG.1: Read voltage (COMMAND ID 2 and 3) on J26[12] and J26[2], respectively.
In this example, the trigger to read ADC values is done via Software (ADC_ETC_START blocks), which is ran at every step execution (once 0.2s).
XBAR0_TRIG.0 triggers the ADC_ETC_IRQ0_IRQHandler interrupt, which read the voltage on J9[10] (Data Memory Chan1) and increment the variable counter_trig0.
XBAR0_TRIG.1 triggers the ADC_ETC_IRQ1_IRQHandler interrupt, which read the voltage on J26[12] (Data Memory Chan2) and J26[2] (Data Memory Chan3) and increment the variable counter_trig1.
Please use the included FreeMASTER project to check the values of all these variables. In the image below, I used a 1.21V reference voltage applied on all 3 channels, one at a time. As there are no pulldown/pullup resistors, if no voltage is applied, the read values is floating around random values.
Best regards,
Sorin Bancila
Hello,
I've attached an example that reads from 3 channels as below:
- XBAR0_TRIG.0: Read voltage (COMMAND ID 1) on J9[10]
-XBAR0_TRIG.1: Read voltage (COMMAND ID 2 and 3) on J26[12] and J26[2], respectively.
In this example, the trigger to read ADC values is done via Software (ADC_ETC_START blocks), which is ran at every step execution (once 0.2s).
XBAR0_TRIG.0 triggers the ADC_ETC_IRQ0_IRQHandler interrupt, which read the voltage on J9[10] (Data Memory Chan1) and increment the variable counter_trig0.
XBAR0_TRIG.1 triggers the ADC_ETC_IRQ1_IRQHandler interrupt, which read the voltage on J26[12] (Data Memory Chan2) and J26[2] (Data Memory Chan3) and increment the variable counter_trig1.
Please use the included FreeMASTER project to check the values of all these variables. In the image below, I used a 1.21V reference voltage applied on all 3 channels, one at a time. As there are no pulldown/pullup resistors, if no voltage is applied, the read values is floating around random values.
Best regards,
Sorin Bancila
Thanks for your example. Is it possible to perform a multi-channel read using just the LPADC blocks, or is it necessary to use the ADC_ETC? I do not need any external hardware triggers but will need a software trigger.
Hello,
Unfortunately, it is not possible to use multiple LPADC blocks. Only way to read multiple channel is to use the ADC_ETC.
The example that I attached in the previous reply includes a multi-channel read, using software triggers (ADC_ETC_Start blocks)..
Best regards,
Sorin Ioanid