RT117x: Multichannel ADC read

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

RT117x: Multichannel ADC read

跳至解决方案
992 次查看
SecularC
Contributor I

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.

0 项奖励
回复
1 解答
885 次查看
SorinIBancila
NXP Employee
NXP Employee

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.

SorinIBancila_0-1742485923450.png

 

Best regards,

Sorin Bancila

在原帖中查看解决方案

0 项奖励
回复
4 回复数
886 次查看
SorinIBancila
NXP Employee
NXP Employee

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.

SorinIBancila_0-1742485923450.png

 

Best regards,

Sorin Bancila

0 项奖励
回复
858 次查看
SecularC
Contributor I

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.

0 项奖励
回复
841 次查看
SorinIBancila
NXP Employee
NXP Employee

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

0 项奖励
回复
961 次查看
SecularC
Contributor I
Bumping
0 项奖励
回复