ADC_ETC sync mode questions on rt1050

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

ADC_ETC sync mode questions on rt1050

Jump to solution
5,367 Views
jackking
Senior Contributor I

I asked a similar question in the MCUXpresso SDK area without a response...

I am a bit confused by ADC_ETC sync mode, unsure of what the trigger chain length should be in sync mode (1?)

Chains aren't really explained in the reference manual.

When using the SYNC mode of the ADC_ETC trigger to trigger both ADC1 and ADC2 simultaneously, is only a single trigger needed? (trig 0 using software) or are two triggers actually used (0 & 1)?

If using a single trigger, how do you configure the channels for both ADC1 and ADC2 in the single trigger config, ADC1 and ADC2 must have different channels, but the trigger only allows specifying one channel.

If both ADC1&2 are both triggered by trigger 0, how can you read the results from both, since the result register only holds the value from one ADC for the trigger? Or do you have to read the results from the ADC results buffers directly? Or will the done0 interrupt be called multiple times, once for each ADC, and the results for the corresponding ADC will be in the same result register?

I have tried both ways in code and don't see the results from ADC2 at all, and the done 0 interrupt is only called once from the trigger.

From this diagram in the Reference Manual, it looks like both ADC are triggered from a single trigger, and the results are stored in the same buffer (RstBuf0?), which I assume would be TRIG0_RESULT_1_0->DATA0 in the case of a single trigger from trigger 0?

IMXRT1050RM_pdf__page_528_of_3_569_.png

Any clarifications are appreciated!  

Labels (2)
1 Solution
4,237 Views
jackking
Senior Contributor I

OK, I have made some progress.  I will leave this here in case someone is struggling with the ADC, chains and triggers.

This application note for the rt1020 is extremely informative, with diagrams and sample code: https://www.nxp.com/docs/en/nxp/application-notes/AN12200.pdf

The sample code for this application note is contained in the Windows executable package available here: https://www.nxp.com/docs/en/nxp/application-notes-software/AN12200SW.exe

Specifically this diagram helped a lot:

Dual_FOC_Servo_Motor_Control_on_i_MX_RT_-_AN12200_pdf.png

So to answer my own question.

The ADC_ETC sync mode should be set true on trigger4 (not trigger 0).  When trigger 0 is executed, trigger 4 will also execute. 

Trigger 0 is tied to ADC1, trigger 4 is tied to ADC2.  So you would set up both triggers 0 and 4, then you would also set up chains for trigger 0 and trigger 4.

Since I only need a single conversion, my chain length is 1 for both triggers.  Both triggers need a configured chain 0 element, with the conversion channel for ADC1 set up on trigger0, chain0  and ADC2 channel on trigger4, chain0.

I fire the Done0 interrupt on trigger0,chain0 and the Done1 interrupt on trigger4, chain0.  Then I know both conversions are complete when both interrupts have fired.

The ADC peripherals need to also be configured.  The one specific setting I found was that ADC_EnableHardwareTrigger should be true for both ADC, although I was expecting this to be false using a software trigger.  The channel numbers don't seem to matter, because they are set explicitly when the chain element executes (with it's own channel config).  The interrupt on conversion complete should be disabled, since we rely on the chain interrupt.

To read the conversion results, you need to read the appropriate trigger/chain register from ADC_ETC. 

So in this case, trigger0/chain0 "ADC_ETC_GetADCConversionValue(ADC_ETC, 0U, 0U)" in the Done0 interrupt

and trigger4/chain0 "ADC_ETC_GetADCConversionValue(ADC_ETC, 4U, 0U)" in the Done1 interrupt.

Hope that will help someone in the future!

View solution in original post

3 Replies
4,238 Views
jackking
Senior Contributor I

OK, I have made some progress.  I will leave this here in case someone is struggling with the ADC, chains and triggers.

This application note for the rt1020 is extremely informative, with diagrams and sample code: https://www.nxp.com/docs/en/nxp/application-notes/AN12200.pdf

The sample code for this application note is contained in the Windows executable package available here: https://www.nxp.com/docs/en/nxp/application-notes-software/AN12200SW.exe

Specifically this diagram helped a lot:

Dual_FOC_Servo_Motor_Control_on_i_MX_RT_-_AN12200_pdf.png

So to answer my own question.

The ADC_ETC sync mode should be set true on trigger4 (not trigger 0).  When trigger 0 is executed, trigger 4 will also execute. 

Trigger 0 is tied to ADC1, trigger 4 is tied to ADC2.  So you would set up both triggers 0 and 4, then you would also set up chains for trigger 0 and trigger 4.

Since I only need a single conversion, my chain length is 1 for both triggers.  Both triggers need a configured chain 0 element, with the conversion channel for ADC1 set up on trigger0, chain0  and ADC2 channel on trigger4, chain0.

I fire the Done0 interrupt on trigger0,chain0 and the Done1 interrupt on trigger4, chain0.  Then I know both conversions are complete when both interrupts have fired.

The ADC peripherals need to also be configured.  The one specific setting I found was that ADC_EnableHardwareTrigger should be true for both ADC, although I was expecting this to be false using a software trigger.  The channel numbers don't seem to matter, because they are set explicitly when the chain element executes (with it's own channel config).  The interrupt on conversion complete should be disabled, since we rely on the chain interrupt.

To read the conversion results, you need to read the appropriate trigger/chain register from ADC_ETC. 

So in this case, trigger0/chain0 "ADC_ETC_GetADCConversionValue(ADC_ETC, 0U, 0U)" in the Done0 interrupt

and trigger4/chain0 "ADC_ETC_GetADCConversionValue(ADC_ETC, 4U, 0U)" in the Done1 interrupt.

Hope that will help someone in the future!

4,237 Views
rost0031b
Contributor II

Thank you very much for posting this. There is absolutely no documentation on what triggers and chains are and how they are to be linked together. I was wondering if you could elaborate a little on what you wrote. For example:

>

jackking wrote:

The ADC_ETC sync mode should be set true on trigger4 (not trigger 0).  When trigger 0 is executed, trigger 4 will also execute. 

 

Trigger 0 is tied to ADC1, trigger 4 is tied to ADC2.  So you would set up both triggers 0 and 4, then you would also set up chains for trigger 0 and trigger 4.

 

Since I only need a single conversion, my chain length is 1 for both triggers.  Both triggers need a configured chain 0 element, with the conversion channel for ADC1 set up on trigger0, chain0  and ADC2 channel on trigger4, chain0.

Is there a reason you chose trigger4 instead of just using trigger 1 or 2?  Does the trigger numbering have some sort of effect?

As far as chains go, does that just control how many conversions are done on the same channel and source?

Thank you in advance

0 Kudos
Reply
3,785 Views
SphCow
Contributor I

I think this is a bit clear from the datasheet which says "Support up to four external trigger inputs for each ADC (trig0~trig3 for ADC1, and trig4~trig7 for ADC2)."

0 Kudos
Reply