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.

TMS320F28379D: Understanding the SOC Signals

Part Number: TMS320F28379D

I am having a bit of difficulty understanding how the SOC signals work.

Let's say I want to capture a few measurements on an ePWM timer zero. In my application, when the PWM timer hits zero, I want to capture single-ended signals on B0, B2, B3, B4, C2, C3, C4, D0, D1 and D2. In my ePWM config, I use the following 

    EALLOW;
    EPwm1Regs.ETSEL.bit.SOCASEL = 1; // Generate SOCA event on ePWM1 timer zero
    EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event. Generates SOCA event on EVERY ePWM1 timer zero
    EPwm1Regs.ETSEL.bit.SOCAEN = 1;  // Enable EPWMxSOCA pulse
    EDIS;

As I understand it, the choice of SOCA is entirely arbitrary and I could just as easily have used SOCB. Is this correct?

Now I move to configuring the ADCs. Now we start to see mention of the SOCs having numbers as well as letters which I'm a bit confused about.

In my ADC code, I do the following:

    /////////////////////////////////////////////
    ////////////// CONFIGURE ADC B //////////////
    /////////////////////////////////////////////
    // -- Configure ADCB to Single-Ended 12-bit Mode -- //
    AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
    AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);  // Set ADC to single ended, 12-bit mode
    AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;  // Generate interrupt pulse at end of conversion
    AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up analogue circuitry in the ADC core (Delay required after).

    // -- Configure channel B0 for reading the DC Link Voltage -- //
    AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0;  // SOC0 will convert pin B0
    AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14; // Sample window is 100 SYSCLK cycles
    AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 5; // trigger on ePWM1 SOCA/C

The first section is fairly simple, however the second section, I know that I'm outputting my trigger from the ePWM on SOCA, so I need to set the ADC to be triggered from SOCA, which I do by setting TRIGSEL to 5 which means ePWM1, ADCSOCA which is consistent with how I set up the ePWM module earlier. However, where do the SOC numbers come in? In the above code I've used SOC0 because that's what is done in the examples. From the TRM chapter on the ADC, it says each ADC has 16 SOCs which contain instructions describing a conversion, so is the choice of which SOC to use completely arbitrary? 

For example, above I convert Channel B1, do I need to use SOC1, or can I use any SOC that I am not already using for something else like this?

    // -- Configure channel B1 for reading the DC Link Voltage -- //
    AdcbRegs.ADCSOC12CTL.bit.CHSEL = 1;  // SOC12 will convert pin B01
    AdcbRegs.ADCSOC12CTL.bit.ACQPS = 14; // Sample window is 100 SYSCLK cycles
    AdcbRegs.ADCSOC12CTL.bit.TRIGSEL = 5; // trigger on ePWM1 SOCA/C

Final question, why does the TI example use the comment "//trigger on ePWM1 SOCA/C"? As I understand it from the ePWM section of the TRM, there are only SOCA and SOCB signals.

 

  • Hi,

    Euan Andrew1 said:
    As I understand it, the choice of SOCA is entirely arbitrary and I could just as easily have used SOCB. Is this correct?


    That's correct. You could choose either SOCA/B.

    Euan Andrew1 said:
    Now I move to configuring the ADCs. Now we start to see mention of the SOCs having numbers as well as letters which I'm a bit confused about.

    Letters are used to designate different ADCs. On this device there are 4 ADCs designated as ADCA/B/C/D.

    Euan Andrew1 said:
    However, where do the SOC numbers come in?

    These SOCs are independent of the Trigger selection/CHannel selection. Please refer to TRM section "11.5 SOC Principle of Operation"
    So, you can potentially configure channel selection and trigger selection for SOCs independently. This is not to be confused with SOCA/B coming from EPWMs.
    Any SOCx in ADC can choose any trigger from (SOCA/B) EPWMn.

    Euan Andrew1 said:
    Final question, why does the TI example use the comment "//trigger on ePWM1 SOCA/C"? As I understand it from the ePWM section of the TRM, there are only SOCA and SOCB signals.

    Not sure why it's commented as SOCA/C, as you said there are only SOCA and SOCB available in EPWM module as triggers to ADC.

  • Thanks for your reply. This has been very useful as always. If I may just clarify a couple of points....

    1. I am using the SOC A pulse from an ePWM module to trigger multiple conversions. Let's say I want to sample B0, B2, B3, B4 and C2. I trigger them all using different SOC numbers, but I don't want to take any action until I have ALL of these results, it would be best to setup an interrupt at the EOC of B4 because ADCB has more conversions to do. Is this correct?
    2. I think what has caused me a great deal of frustration here is that I had wrongly assumed that the ADCRESULTx was tied to Channel X rather than SOCx. For example I was triggering channel B0 using SOC6 then looking for the result in ADCRESULT0 when I should have been looking in ADCRESULT6. Am I understanding this correctly now?
    3. Each ePWM peripheral can produce a SOCA and a SOCB signal. In this context, SOC is nothing more than a pulse. However, in the ADCs, SOC refers to a configuration set, inside which we can chose to respond to a SOCA or SOCB signal from any of the EPWM modules using the TRIGSEL options. Am I now correct on this?

    Sorry for what are probably very basic questions but I am trying to get the basics right!

  • Hi,

    Euan Andrew1 said:
    I am using the SOC A pulse from an ePWM module to trigger multiple conversions. Let's say I want to sample B0, B2, B3, B4 and C2. I trigger them all using different SOC numbers, but I don't want to take any action until I have ALL of these results, it would be best to setup an interrupt at the EOC of B4 because ADCB has more conversions to do. Is this correct?

    Correct.

    Euan Andrew1 said:
    I think what has caused me a great deal of frustration here is that I had wrongly assumed that the ADCRESULTx was tied to Channel X rather than SOCx. For example I was triggering channel B0 using SOC6 then looking for the result in ADCRESULT0 when I should have been looking in ADCRESULT6. Am I understanding this correctly now?


    You are correct again. As I said earlier, SOCx can be configured to work with any Channel, trigger. Yes - Result is tied to SOCx.

    Euan Andrew1 said:
    Each ePWM peripheral can produce a SOCA and a SOCB signal. In this context, SOC is nothing more than a pulse. However, in the ADCs, SOC refers to a configuration set, inside which we can chose to respond to a SOCA or SOCB signal from any of the EPWM modules using the TRIGSEL options. Am I now correct on this?
     

    This is correct as well. I guess, the terminology of SOC in ADC vs EPWM is causing some confusion.

  • Thanks again.

    Yes the first issue with misunderstanding where the result would be found was down to my own sloppy reading of the TRM.

    As for the confusion between the use of SOC in the ePWM vs the ADC, I think this is potentially unclear to a new user. I had it in my head that I wanted to send something out of the ePWM to trigger a conversion, so I looked to the ePWM chapter and found that I could output a "Start of Conversion" signal. "Great I thought". Then I went to the ADC section and thought "Hang on, a minute ago I only had SOCA and SOCB, now there's no mention of A and B but there's now SOC0 through 15".

    In my humble opinion, it would have been nice if the signals coming out of the ePWM modules were called "Trigger A" and "Trigger B". This would avoid confusion between SOCA/B and SOC0-15. It would also tie in nicely with the fact that you then go on to select the one you want to use by setting a TRIGSEL register.

    In any event... my issue is resolved.