Reading two AD inputs with ADC_ETC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading two AD inputs with ADC_ETC

Jump to solution
1,253 Views
JLa63
Contributor I

Hi all,

I have just started working with MIMXRT1060-EVKB devkit and tried to modify the example evkbmimxrt1060_adc_etc_software_trigger_conv to read two AD inputs from J33 connector: A0/ADC0 and A1/ADC1.

I have thought that when reading two AD inputs with software trigger you can use the same trigger group with chain numbers 0 and 1, as I've done in the attached modified example.

However with the modified code I only get value of the ADC1 input, ADC0 is always read as 0.

I know that similar cases have been handled in this forum but I haven't been able to solve the problem by examining them.

Any help appreciated,
Rgrds Jukka

 

0 Kudos
1 Solution
1,204 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

ADC_EnableHardwareTrigger() set ADC->CFG[ADTRG] bit. It selects the type of trigger used for initiating a conversion. Two types of trigger are selectable: software trigger and hardware trigger. When software trigger is selected, a conversion is initiated following a write to ADC_HC0. When hardware trigger is selected, a conversion is initiated following the assertion of a pulse on Alternate Hardware trigger input along with the assertion of the enable of respective the hardware Triggers input.

 

Regards,

Jing

View solution in original post

0 Kudos
6 Replies
1,236 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @JLa63 ,

But you only initialized ADC1. ADC2 isn't initialized.

 

Regards,

Jing

0 Kudos
1,223 Views
JLa63
Contributor I

Hi Jing,

Thanx for the response.

Namings and labels may be a bit confusing:
* default example evkbmimxrt1060_adc_etc_software_trigger_conv initializes Arduino connector J33 pin A0/ADC0 of the devkit board
- that is ADC instance ADC1 channel #15, pin number GPIO_AD_B1_10
- this example works fine

* in the modified code I added Arduino connector J33 pin A1/ADC1 of the devkit board
- that is ADC instance ADC1 channel #0, pin number GPIO_AD_B1_11
- with this example only ADC1 channel #0 is read correctly, original ADC1 channel #15 is always zero

When the above is taken into account, what exactly do you mean by ADC2 in your response? ADC instance? I intended to use two different channels of the ADC1 instance.

Best regards,
Jukka

0 Kudos
1,214 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @JLa63 ,

Then you only want to use one ADC instance. I attached my example, this is for RT1170. But the ADC_ETC part should same.  please take a lot.

 

Regards,

Jing

0 Kudos
1,210 Views
JLa63
Contributor I

Thanx again Jing, the problem solved.

Actually only change needed was to set the adcEtcTriggerChainConfig.enableB2BMode = true, then both the inputs worked fine!

One additional question though to clear my mind:

Why is the hardware trigger enabled in the following call of the example:

   ADC_EnableHardwareTrigger(DEMO_ADC_BASE, true);

though the example uses software trigger and the documentation says: "@param enable Switcher of the trigger mode. "true" means hardware trigger mode,"false" means software mode."

Regards, Jukka

0 Kudos
1,205 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

ADC_EnableHardwareTrigger() set ADC->CFG[ADTRG] bit. It selects the type of trigger used for initiating a conversion. Two types of trigger are selectable: software trigger and hardware trigger. When software trigger is selected, a conversion is initiated following a write to ADC_HC0. When hardware trigger is selected, a conversion is initiated following the assertion of a pulse on Alternate Hardware trigger input along with the assertion of the enable of respective the hardware Triggers input.

 

Regards,

Jing

0 Kudos
1,201 Views
JLa63
Contributor I

Hi Jing,

Here the source for the confusion is that there are two places of hw/sw -trigger: ADC and ADC-ETC, and one must understand that SW-trigger in ADC-ETC generates HW-trigger to ADC.

However this discussion cleared a lot of things, but for the future, it maybe good idea to generate an example with two or more AD-inputs used. Or alternatively write an application note to explain these somewhat cryptic peripherals and their interconnections. It would save time for the developers and for the support also.

All the best,

Jukka

0 Kudos