Hi
Background: In an existing projects I have moved some some ADC signals from chain 1/5 to chain 0/4.
Chain length of 1/5 was reduced by one (4->3) and chain length 0/4 increased by one (1->2).
The signal removed from 1/5 was the 2nd in the chain.
So in my code (example for chain 1) I changed code from this
#define ADC_INPUT_IFBK1 4
#define ADC_INPUT_DCLINK 5
#define ADC_INPUT_ANIN1_V 6
#define ADC_INPUT_ANIN2_V 7
#define ADC_INPUT_IFBK2 12
#define ADC_INPUT_HS_T 13
#define ADC_INPUT_ANIN1_I 14
#define ADC_INPUT_ANIN2_I 15
#define ADC1_0 ADC_INPUT_IFBK1
#define ADC1_1 ADC_INPUT_DCLINK
#define ADC1_2 ADC_INPUT_ANIN1_V
#define ADC1_3 ADC_INPUT_ANIN2_V
#define ADC2_0 ADC_INPUT_IFBK2
#define ADC2_1 ADC_INPUT_HS_T
#define ADC2_2 ADC_INPUT_ANIN1_I
#define ADC2_3 ADC_INPUT_ANIN2_I
...
adcEtcTriggerConfig.triggerChainLength = 3U; /* Chain length is 4. */
...
ADC_ETC_SetTriggerConfig(ADC_ETC, 1U, &adcEtcTriggerConfig);
adcEtcTriggerChainConfig.enableB2BMode = true;
// Current feedback 1
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 0U; /* Select ADC_HC0 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_0;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 0U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain0. */
// Link volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 1U; /* Select ADC_HC1 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_1;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 1U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain1. */
// Anin 1 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 2U; /* Select ADC_HC2 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_2;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 2U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain1. */
// Anin 2 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 3U; /* Select ADC_HC3 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_3;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_Done1InterruptEnable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 3U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain2. */
to
...
adcEtcTriggerConfig.triggerChainLength = 2U; /* Chain length is 3. */
...
ADC_ETC_SetTriggerConfig(ADC_ETC, 1U, &adcEtcTriggerConfig);
adcEtcTriggerChainConfig.enableB2BMode = true;
// Current feedback 1
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 0U; /* Select ADC_HC0 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_0;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 0U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain0. */
// Anin 1 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 1U; /* Select ADC_HC1 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_2;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 1U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain1. */
// Anin 2 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U <<2 U; /* Select ADC_HC2 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_3;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_Done1InterruptEnable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 2U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain2. */
I also changed (moved) the readout positions in result registers.
After doing so conversion results were not like expected.
Ain 1 result was read as Anin2 by firmware result and Ain2 was not read in at all anymore.
I started wondering what is going wrong (I had set the ADCChannelSelect correctly (moved to TRIGa_CHAIN_y.CSEL) and also ADCHCRegisterSelect (moved to TRIGa_CHAIN_y.HWTS).
After playing around a bit I have found out that it seems to be the case that
adcEtcTriggerChainConfig.ADCHCRegisterSelect (copied to TRIGa_CHAIN_y.HWTS) defines the one of the possible (configurable) 15 ADC channels to be converted by this chain entry (and not is like I assume the trigger used for this chain entry).
The linkage of this ADCx_0..15 chain number and possible ADC inputs is (I assume) defined by ADCx_HCyADC.ADCH entry.
In my case the definition is
adcChannelConfigStruct.enableInterruptOnConversionCompleted = false;
adcChannelConfigStruct.channelNumber = ADC1_0;
ADC_SetChannelConfig(ADC1, 0U, &adcChannelConfigStruct);
adcChannelConfigStruct.channelNumber = ADC1_1;
ADC_SetChannelConfig(ADC1, 1U, &adcChannelConfigStruct);
adcChannelConfigStruct.channelNumber = ADC1_2;
ADC_SetChannelConfig(ADC1, 2U, &adcChannelConfigStruct);
adcChannelConfigStruct.channelNumber = ADC1_3;
ADC_SetChannelConfig(ADC1, 3U, &adcChannelConfigStruct);
Meaning that ANin 1 (1_2) is assigned to ADC channel 2 and ANin 2 (1_2) is assigned to ADC channel 3.
After changing the code to
// Anin 1 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << 2U; /* Select ADC_HC2 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_2;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_InterruptDisable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 1U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain1. */
// Anin 2 volts
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U <<3 U; /* Select ADC_HC3 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = ADC1_3;
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_Done1InterruptEnable; /* No interrupt, A/D interrupt used instead of*/
ADC_ETC_SetTriggerChainConfig(ADC_ETC, 1U, 2U, &adcEtcTriggerChainConfig); /* Configure the trigger1 chain2. */
conversion is working (again).
What I now wonder is what the ADCChannelSelect (moved to TRIGa_CHAIN_y.CSEL) is used for (as the physical analog input source seems to be defined by the AC chain channel assignment done via HC register).
In my code it is set to the same entry as the physical input source selection (e.g. ADC1_3).
So please shed some light into meaning of register entries.
TRIGa_CHAIN_1_0.CSEL and .HWTS
and ADCx_HC0ADC.ADCH
in case of ADC_ETC operation in hardware trigger mode.
Thomas
Hi
I checked the AN 13097 but the relation between chanel configuration HC and ETC also is not clearly decribed. The document more is related to "triggers" somehow. Also the meaning of expression as not clear for me.
e.g. this sentence mentions trigger and commands
"This trigger passes again through the ADC_ETC arbiter and the synchronization module to the ADC1. Now the chain
1 configuration (HTWS1 and CSEL1) defines what trigger and command within the ADC1 module will be used for the
conversion."
Thomas
Hi.
So theoretically I could set
adcEtcTriggerChainConfig.ADCChannelSelect
to
0,1,2
instead of
ADC1_0,ADC1_3,ADC1_4 (what means I set currently the channel used to the same value as used input selection)
I also must say that the documentation is no very precise and understandable here.
Is there maybe the same ADC used in some other product but with better documentation?
It really is also not clear from that example....
Hi,
Thanks for your reply.
Yes, you can set the adcEtcTriggerChainConfig.ADCChannelSelect to
0,1,2.
You can refer to the application note to learn ADC hardware triggering capability implementation.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
The TRIGx_CHAIN_1_0.HWTS seems to be the map of ADC1_HCn, and
The TRIGx_CHAIN_1_0.CSEL stands for the sample channel of the ADC.
For ADC_ETC hardware trigger mode, the corresponding ADCADC1_HCn[ADCH] should be set to 0x10, you can refer to the adc_etc_hardware_trigger_conv in the SDK library for details.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------