This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28335: Simultaneous sampling mode for ADC

Part Number: TMS320F28335

I want to use the simultaneous sampling mode of the ADCs in F28335. Currently, I have set them up for sequential sampling. The start of conversion is triggered as follows:

ADC A: Triggered by ePWM1

ADC B: Triggered by ePWM3

The ADCs A and B post their own interrupts. So my question is that they are sampled accordingly in their respective ISRs, correct?


So, if I use the simultaneous sampling mode, since both ADCs will be sampled together, should I sample them both in a single ISR? Also, should the interrupt be generated by ADC A or ADC B? If my question does not make sense, please excuse and help.

  • Hi Rohit,

    If you have 2 separate sequencers (SEQ1 and SEQ2) configured on this device, they won't be tied to ADC S+H A or ADC S+H B. You can convert whatever ADC channels you want in each of these sequences and the results go to the corresponding ADC result registers. SEQ1 is, however, only triggered by ePWM SOC A and SEQ 2 is only triggered by ePWM SOC B (but these ePWM triggers don't limit what ADC channels can be sampled in each sequence).

    When you enable simultaneous sampling mode you can again select whatever channels you want and in whatever order in a given SEQ. The only difference is that for one channel configuration you get 2 results placed in the result registers, one from S+H A and one from S+H B. You can still use the normal end-of-sequence interrupts to read the results.
  • So what is the benefit of simultaneous sampling mode? Or more like what purpose does simultaneous sampling serve? If the SOC for ADC A and ADC B are separated in time, then does it mean that in simultaneous sampling, if ADC B SOC is not activated, only ADC A is sampled? Please explain.
  • Hi Rohit,

    Simultaneous sampling allows two voltages to be sampled at the same time (the voltages are still converted sequentially). These voltages are on different S+Hs (A or B) but get converted in the same ADC (there is only one ADC). This is good for applications that want samples with the same sampling instant (e.g. motor control with multiple motor phases).

    I think you may be conflating S+H and SOC, so I'll again state that a given SOC A or SOC B (these are configurable triggering times in the ePWM timebase) has no correlation with ADC S+H A or S+H B (these are channel groups for the ADC). You can sample ADC input B3 from the SOCA trigger, you can simultaneously sample ADC inputs A2 and B2 then A4 and B4 from SOCB trigger, ...etc
  • Devin, I still do not understand this clearly. I will present four scenarios and tryto describe the workflow. Please tell me if it is right and please correct if it is wrong.

    Case 1. ePWM 1 triggers SOC A and ePWM 3 triggers SOC B. The triggers are 5 us apart. Simultaneous sampling is enabled.
    1. When SOC A arrives.

    2. ADC A samples A0, B0, A1, B1 and A2, B2 are sampled because of simultaneous sampling being enabled, even though SOC B has not arrived.
    2. Interrupt is posted when conversion in either ADC is finished. All the six channels' results are sent to variables as needed.
    3. 5us later from SOC A, SOC B arrives. Then, steps 2 and 3 are repeated.

    Case 2. ePWM 1 triggers both SOC A and SOC B. Simultaneous mode is enabled.
    1. SOC A and SOC B arrive together. Channels A0, B0, A1, B1, A2 and B2 are sampled in the mentioned order.
    2. Interrupt is posted. Values are transferred to variables.

    Case 3. ePWM 1 triggers SOC A and ePWM 3 SOC B. Triggers are 5 us apart. Sequential sampling mode is enabled.
    1. SOC A arrives and A0, A1 and A2 are sampled. ADC B is not sampled.
    2. Interrupt is posted with EOS for ADC A. Values from A0, A1 and A2 are transferred to variables.
    3. SOC B arrives 5us later than SOC A. B0, B1 and B2 are sampled. ADC A is not sampled.
    4. Interrupt is posted with EOS for ADC B. Values from B0, B1 and B2 are transferred to variables.

    Case 4. ePWM1 triggers SOC A and SOC B. Sequential mode is enabled.
    1. SOC A and SOC B arrive. A0, A1, A2, B0, B1 and B2 are sampled in the order mentioned.
    2. Interrupt is posted for EOS of either of ADCs and values are transferred from all six channels to desired variables.

    I think that I am using Case 3 as of now and I intend to go to Case 2. Please clarify if my explanation is wrong.

    Additionally, if my understanding is correct, there are following modes for the ADC:

    1. Sequential mode

    2. Simultaneous sampling mode

    a. 2 Sequencers with 8 values each

    b. 1 cascaded sequencer with 16 values

    My question is that if my understanding of the modes is correct, then what is the difference between sequential mode and the simultaneous mode with cascaded sequencer?

  • Hi Rohit,

    Looking at case 3:

    Case 3. ePWM 1 triggers SOC A and ePWM 3 SOC B. Triggers are 5 us apart. Sequential sampling mode is enabled.
    1. SOC A arrives and A0, A1 and A2 are sampled. ADC B is not sampled.
    2. Interrupt is posted with EOS for ADC A. Values from A0, A1 and A2 are transferred to variables.
    3. SOC B arrives 5us later than SOC A. B0, B1 and B2 are sampled. ADC A is not sampled.
    4. Interrupt is posted with EOS for ADC B. Values from B0, B1 and B2 are transferred to variables.

    There is no need for SOCA to only trigger A channels.  You could just as easily do:

    1. SOC A arrives and A0, B3, and A1 are sampled (sequentially).  

    If you look at the channel select register in the ADC user's guide (spru812a) you see that you can actually select any channel:

    Now in sequential mode you could also sample:

    1. SOC A arrives and A2, B2, A5, B5 are sampled (sequentially).  

    And A2 and B2 would be reasonably close in time, but not identical.  Instead, if you configure for simultaneous mode you can do the same thing:

    1. SOC A arrives and A2, B2, A5, B5 are sampled (A2+B2 and A5+B5 are simultaneous).  

    And now your A2 and B2 samples are captured at the same instant, which is advantageous for some applications.  You would, however, loose the flexibility to not sample A and B channel pairs (so you couldn't do A2, B2, A5, B7 for instance).  

    Now as far as what to do with the SOCB trigger, you can use this to sample the same set of signals, or you can use it to sample a completely different set of signals.  Both of these would be valid configurations (sequential mode):

    Case 3a. ePWM 1 triggers SOC A and ePWM 3 SOC B. Triggers are 5 us apart. Sequential sampling mode is enabled.
    1. SOC A arrives and A0, B1 and B7 are sampled. 
    2. Interrupt is posted with EOS for ADC SOC A. Values from A0, B1 and B7 are transferred to variables.
    3. SOC B arrives 5us later than SOC A. A0, B1 and B7 are again sampled. 
    4. Interrupt is posted with EOS for ADC SOC B. Values from A0, B1 and B7 are transferred to variables.

    Case 3b. ePWM 1 triggers SOC A and ePWM 3 SOC B. Triggers are 5 us apart. Sequential sampling mode is enabled.
    1. SOC A arrives and A0, B1 and B7 are sampled. 
    2. Interrupt is posted with EOS for ADC SOC A. Values from A0, B1 and B7 are transferred to variables.
    3. SOC B arrives 5us later than SOC A. A5, B5 and B0 are sampled. 
    4. Interrupt is posted with EOS for ADC SOC B. Values from A5, B5 and B0 are transferred to variables.

    The difference between 3a and 3b is how the channel selects are configured.  

  • Hi Devin, this clears things up a lot. This brings me to one last question:

    1. I want to sample ADC A0, B0 and ADC A2, B2 together at say time t=0.

    2. I want to sample ADC A1 and B1 together at say time t=5us.

    My question is that how do I configure the registers that SOC A leads to A0, B0 and A2, B2 being sampled, while SOC B leads to A1 and B1 sampled. Since I want pairs, based on my description, simultaneous sampling is needed, which is pretty clear.

    The above has been what I want to do all along.

  • Hi Rohit,

    Check out Example 1-1. "Simultaneous Sampling Dual Sequencer Mode Example" in the ADC user's guide (http://www.ti.com/lit/ug/spru812a/spru812a.pdf

  • (the rest of the post got cut off above)

    This example shows how to use 2 sequencers in simultaneous mode with 4 pairs of conversions on each SEQ. To get what you want, you would want to change maxconv on SEQ1 to '1' and maxconv on SEQ2 to '0'. You would then also want to change the channel selects for your specific channels:

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0 //A0 and B0 on SEQ1
    AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 2 //A2 and B2 on SEQ1
    AdcRegs.ADCCHSELSEQ1.bit.CONV07 = 1 //A1 and B1 on SEQ2

    Note: If you actually want A0, B0, A2, and B2 to all be at the same time, you can use the trick of sandwiching the CH0 conversions between two CH2 conversions...SEQ1 would be CH2->CH0->CH2. You then can average the channel 2 samples together to get samples with an average time that is the same as the CH0 samples. This isn't quite as good as sampling all 4 at the same time, but it is a little better than two sequential pairs.
  • Hi Devin. Thank you for the explanation. So, this means that when a SOC trigger arrives (whether it is SOC A or SOC B), then a maximum of 16 conversions can happen. Now the ADC channels on which these conversions are to happen is determined by the contents of the sixteen 4 bit CONVnn bit fields and the process starts from conversion of channel pointed by CONV0 and ends with conversion of channel in CONV15 (or sooner it MAXCONV is set to less than 15). These channels can be anything from A0 to B7. The interrupt generated is either from SOC A or SOC B (whichever trigger started the conversion).

    Now in Case 2 described above, ePWM1 triggers both SOC A and SOC B. If SOC A is to sample say, A0, A1, B0, B1, while SOC B is set to sample A2, B2, A3, B3. Since SOC A and SOC B arrive simultaneously, which channels are sampled? Which SOC takes precedence, or is one SOC ignored altogether?


    I also notice that there is an ADCINT interrupt, that is in the PIE table at x=1, y=6. What is the role of this interrupt, when there are two sequencer interrupts at x=1, y=1 and x=1, y=2? Please explain?

  • Hi Rohit,

    Up to 16 conversions can be processed in cascaded sequencer mode or 8 conversions from each sequence in dual-sequencer mode. Since each sequence in dual-sequencer mode can only processes up to 8 conversions, you will want to set the maxconv setting to less than '3' if you are using simultaneous sampling mode.

    In simultaneous dual sequencer mode, CONV00, '01, '02', and '03 select the up to 8 channels converted by SEQ1 and CONV07,'08,'09,and '10 select the up to 8 channels converted by SEQ2.

    The behavior when both triggers arrive at the same time is specified in the ADC user's guide in the section "1.2 Autoconversion Sequencer Principle of Operation" or "Table 1-2. Comparison of Single and Cascaded Operating Modes"

    I'm actually not sure on the different interrupts - the documentation isn't very clear here; I'll have to get back to you on this. My guess is that ADCINT and SEQ1INT are alternate mappings of the same interrupt.