Hi,
I'm trying to configure ADC_ETC to start conversions on ADC2. With help from Config Tool, IO have set up two conversion chains. One using ADC1 and one using ADC2.
The one using ADC1 works perfectly.
The one using ADC2 are using the channels configured for ADC1.
I'm using SW triggers.
In the Config Tool I cannot see any effect by changing the "Trigger source". The reference manual says that to use ADC2 you have to use "trig4~trig7", but the Config Tool only shows "XBARx_TRIG 0-3". Is XBAR1, TRIG 0-3 the same as trig4~trig7? Using this still uses the configuration from ADC1.
Here some of my init code (I have shrinked it to 2 times 2 channels):
from peripherals.c:
const adc_etc_config_t ADC_ETC_config = {
.clockPreDivider = 1,
.dmaMode = kADC_ETC_TrigDMAWithLatchedSignal,
.enableTSCBypass = true,
.enableTSC0Trigger = false,
.enableTSC1Trigger = false,
.TSC0triggerPriority = 0,
.TSC1triggerPriority = 0,
.XBARtriggerMask = 0
};
/* ADC_ETC triggers configuration */
const adc_etc_trigger_config_t ADC_ETC_trigger_config[2] = {
{
.triggerPriority = 1,
.enableSWTriggerMode = true,
.enableSyncMode = false,
.initialDelay = 0,
.sampleIntervalDelay = 1,
.triggerChainLength = 1
},
{
.triggerPriority = 1,
.enableSWTriggerMode = true,
.enableSyncMode = false,
.initialDelay = 0,
.sampleIntervalDelay = 1,
.triggerChainLength = 2
}
};
/* ADC_ETC chain configurations for appropriate (see name of these arrays) trigger configuration */
const adc_etc_trigger_chain_config_t ADC_ETC_TC_0_chain_config[2] = {
{
.enableB2BMode = true,
.ADCHCRegisterSelect = 1,
.ADCChannelSelect = 0,
.InterruptEnable = kADC_ETC_InterruptDisable,
},
{
.enableB2BMode = true,
.ADCHCRegisterSelect = 2,
.ADCChannelSelect = 1,
.InterruptEnable = kADC_ETC_InterruptDisable,
}
};
const adc_etc_trigger_chain_config_t ADC_ETC_TC_1_chain_config[2] = {
{
.enableB2BMode = true,
.ADCHCRegisterSelect = 1,
.ADCChannelSelect = 8,
.InterruptEnable = kADC_ETC_InterruptDisable,
},
{
.enableB2BMode = true,
.ADCHCRegisterSelect = 2,
.ADCChannelSelect = 12,
.InterruptEnable = kADC_ETC_InterruptDisable,
}
};
static void ADC_ETC_init(void) {
ADC_ETC_Init(ADC_ETC_PERIPHERAL, &ADC_ETC_config);
NVIC_SetPriority(ADC_ETC_ADC_ETC_0_IRQN, ADC_ETC_ADC_ETC_0_IRQ_PRIORITY);
EnableIRQ(ADC_ETC_ADC_ETC_0_IRQN);
NVIC_SetPriority(ADC_ETC_ADC_ETC_1_IRQN, ADC_ETC_ADC_ETC_1_IRQ_PRIORITY);
EnableIRQ(ADC_ETC_ADC_ETC_1_IRQN);
NVIC_SetPriority(ADC_ETC_ADC_ETC_ERROR_IRQN, ADC_ETC_ADC_ETC_ERROR_IRQ_PRIORITY);
EnableIRQ(ADC_ETC_ADC_ETC_ERROR_IRQN);
}
My Init code:
static void adc_init_peripherals_h(void)
{
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, &ADC_ETC_trigger_config[ADC_ETC_TC_0]);
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 0U, &ADC_ETC_TC_0_chain_config[0]);
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 1U, &ADC_ETC_TC_0_chain_config[1]);
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1, &ADC_ETC_trigger_config[ADC_ETC_TC_1]);
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1, 0U, &ADC_ETC_TC_1_chain_config[0]);
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1, 1U, &ADC_ETC_TC_1_chain_config[1]);
}
Starting conversions:
void adc_start(void)
{
ADC_ETC_DoSoftwareTrigger(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0);
ADC_ETC_DoSoftwareTrigger(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1);
}
ISR:
void ADC_ETC_ADC_ETC_0_IRQHANDLER(void) {
resultsAdc1[0] = ADC_ETC_GetADCConversionValue(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 0U);
resultsAdc1[1] = ADC_ETC_GetADCConversionValue(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 1U);
ADC_ETC_ClearInterruptStatusFlags(ADC_ETC, ADC_ETC_TC_0, kADC_ETC_Done0StatusFlagMask);
}
void ADC_ETC_ADC_ETC_1_IRQHANDLER(void) {
resultsAdc2[0] = ADC_ETC_GetADCConversionValue(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1, 0U);
resultsAdc2[1] = ADC_ETC_GetADCConversionValue(ADC_ETC_PERIPHERAL, ADC_ETC_TC_1, 1U);
ADC_ETC_ClearInterruptStatusFlags(ADC_ETC, ADC_ETC_TC_1, kADC_ETC_Done1StatusFlagMask);
}
Do I do anything wrong?
Solved! Go to Solution.
This post clarifies a lot. It is written for the RT1050, but the facts are similar.
https://community.nxp.com/t5/i-MX-RT/ADC-ETC-sync-mode-questions-on-rt1050/m-p/844735
For the RT1060, the easies way to do the configuration is to assume the configurated trigger chain order defines the trigger chain number. As ADC2 needs to be linked to trigger chain 4-7, I had to define 3 dummy trigger chains, for using trigger chain 0 an 4. When generating code use the "Initialize configuration", but then copy the code initializing the chains to your own code space like below. Please note that all "ADC_ETC_TC_*_TG" are changed to "ADC_ETC_TC_*" to fix the bug in the config tool. Afterward you can remove the "Initialize configuration", and regenerate the code.
static void adc_init_from_peripherals_c(void)
{
/* This should have been in peripherals.c, but is wrongly generated. */
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, &ADC_ETC_trigger_config[ADC_ETC_TC_0]);
/* Initialize ADC_ETC chain configuration for trigger 0. */
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 0U, &ADC_ETC_TC_0_chain_config[0]);
/* Initialize ADC_ETC trigger 0. */
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_4, &ADC_ETC_trigger_config[ADC_ETC_TC_4]);
/* Initialize ADC_ETC chain configuration for trigger 0. */
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_4, 0U, &ADC_ETC_TC_4_chain_config[0]);
}
Hello Guys,
i have a similar problem. I want to use the ADC2 as well. I dont use the config tool. In my adc_etc config, the parameter "adcEtcConfig.XBARtriggerMask" is 1U, as i copied it from the ad_etc example which used ADC1. Do i need to change it to 4U when using ADC2?.
The example defines for the XBAR are as follows:
#define DEMO_XBARA_BASE XBARA1
#define DEMO_XBARA_INPUT_PITCH0 kXBARA1_InputPit1Trigger0
#define DEMO_XBARA_OUTPUT_ADC_ETC kXBARA1_OutputAdcEtc0Coco0
i guess i have to change the output to etc1coco0 according to the RM.
Should it work with this config?
best regards
Anyone have some experience in using ADC_ETC and ADC2?
Hi kl,
Yes, ADC_ETC_TRIG00 ... ADC_ETC_TRIG13 corresponding to trg0 ... trg7, see the NOTE in XBAR resource Assignments in reference manual. But yes, the name seems not match in Config Tool window. There isn't anything called XBAR0 in RM.
Regards,
Jing
This post clarifies a lot. It is written for the RT1050, but the facts are similar.
https://community.nxp.com/t5/i-MX-RT/ADC-ETC-sync-mode-questions-on-rt1050/m-p/844735
For the RT1060, the easies way to do the configuration is to assume the configurated trigger chain order defines the trigger chain number. As ADC2 needs to be linked to trigger chain 4-7, I had to define 3 dummy trigger chains, for using trigger chain 0 an 4. When generating code use the "Initialize configuration", but then copy the code initializing the chains to your own code space like below. Please note that all "ADC_ETC_TC_*_TG" are changed to "ADC_ETC_TC_*" to fix the bug in the config tool. Afterward you can remove the "Initialize configuration", and regenerate the code.
static void adc_init_from_peripherals_c(void)
{
/* This should have been in peripherals.c, but is wrongly generated. */
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, &ADC_ETC_trigger_config[ADC_ETC_TC_0]);
/* Initialize ADC_ETC chain configuration for trigger 0. */
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_0, 0U, &ADC_ETC_TC_0_chain_config[0]);
/* Initialize ADC_ETC trigger 0. */
ADC_ETC_SetTriggerConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_4, &ADC_ETC_trigger_config[ADC_ETC_TC_4]);
/* Initialize ADC_ETC chain configuration for trigger 0. */
ADC_ETC_SetTriggerChainConfig(ADC_ETC_PERIPHERAL, ADC_ETC_TC_4, 0U, &ADC_ETC_TC_4_chain_config[0]);
}
Hi Jing
I just tried to change the trigger source for the trigger chain. It seems that the change does not reflect into any code change. So the trigger source is probably not changed to any signal that triggers ADC2.
Therefore it triggers the trigger chain configured for ADC1 instead.
I only plan to use SW triggers, but I tried to configure the last spare pin as a trigger source for XBAR1_TRIG, 0, and configure my trigger chain 1 to use this as trigger:
But I cannot find any generated code that routes the trigger source to the trigger chain.
I have tried to find the ADC_ETC registers (in the RM) that maps the HW triggers to the trigger chains with no luck. I wander, is it fixed to the trigger chain number (also called "trigger group"? in the config tool, I'm confused)? So I have to use trigger chain 4-7 to trigger conversions on ADC2?
Can you clarify this?
Regard
Kasper
Hi Kasper,
yes, you're right. It should use adc_etc_config_t.XBARtriggerMask to select trig source. But Config Tool only keep it as 1. I'll report this problem.
Please refer to adc_etc_hardware_trigger_conv demo.
Regards,
Jing
Hi Jing
Yes, the XBARtriggerMask is crappy generated, but it is only related to HW triggers. The logic behind the generation is not very clear. And it is not clearly related to the XBAR configured in the Pin-config page of the Config Tool.
But the problem I see is two things. First of all the Trigger source configuration for the trigger chains (the drop down box with the signals from the XBAR) is not having any effect. But the second thing is, that I cannot find the special function register, it should be loaded into. It is verified that the same trigger is not used for multiple chains.
But all this might not be related to my problem, as I am using software triggers. And I am not able to trig a chain using ADC2, as it triggers the channels configured for ADC1. I do not know which ADC that is actually used for the conversion.
Do you have a plan for a new release of the Config tool? I have found around 3 (annoying) bugs.
Kasper
Hi Kasper,
I've report this error. Hope the IDE team can fix it as soon as possible. But I don't know when it can be done.
Regards,
Jing