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.