Hello Community!
So I'm looking to set up the ePWM and the HRPWM on the F28335 for both the ADC and for a variable duty cycle output. Starting with the PWM output, did I read correctly that the duty cycle only has 8 settings about 12-1/2% apart? As for using the ePWM to trigger the SOC on the ADC, I took a look at the example code in the AdcSoc Example file,and modified it. I would like my sample rate to be 40kHz so I left the ADC clock at it's fastest setting, and I assume that changing TBPRD will set the period based on the system clock settings, which should be 150MHz for my application. Therefore, the value I need for TBPRD should be 150MHZ/40kHz = 3750 = 0x0EA6? and how does one determine the value for CMPA? Here's what I came up with, someone please let me know if this looks correct? :
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOC on A group
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC from from CPMA on upcount
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
EPwm1Regs.CMPA.half.CMPA = 0x03A9; // Set compare A value 0x0080~0.25(0xFFFF)
EPwm1Regs.TBPRD = 0x0EA6; // Set period for ePWM1 0xFFFF=2.28kHz? ==> 0x0EA6=40kHz
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // count up and start