I believe there are a few major bugs in the code examples shown in the document for the SFO library SPRUG02. In that document, it states the PWM_CH needs to be 1+ the number of channels in use. There is also a definition for
volatile struct EPWM_REGS *ePWM[PWM_CH] which is where one of the problems is. The first element should be "0" not &EPwm1Regs, otherwise you will always need to enable one more PWM than what's actually used (in addition to setting PWM_CH to 1+ the number of channels used). This bug cost me about 1/2 a day's work in trying to figure out why my SFO code doesn't work.
The other bug I found in this document is in the code shown for example 4.
for(i=1; i<PWM_CH; i++) //for channels 1-16
{
While (SFO_MepDis_V5(i) == 0); //Calls MepDis unitl MEP_ScaleFactor updated
}
There's no way a C compiler will compile this code with the "While" statement the way it is. It's obvious no one tried to use this code. Don't you guys check this stuff before offering it to new developers trying to use your products?
Also, while I'm debugging your code for you, in the document SPRUG0A, the definitions in Example 2.1 won't work.
// TZSEL (Trip-zone Select)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// CBCn and OSHTn bits
#define TZ_ENABLE 0x0
#define TZ_DISABLE 0x1
// TZCTL (Trip-zone Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// TZA and TZB bits
#define TZ_HIZ 0x0
#define TZ_FORCE_HI 0x1
#define TZ_FORCE_LO 0x2
#define TZ_DISABLE 0x3
// ETSEL (Event-trigger Select)
There's 2 "TZ_DISABLE" defined!! Again, who is responsible for checking this stuff??
Want more? In the same example code,
// CBCn and OSHTn bits
#define TZ_ENABLE 0x0
#define TZ_DISABLE 0x1
Are reversed! Enable is "1".
Don't you folks realize people cut and paste this stuff expecting it to work, since it's from the manufacturer??
VERY FRUSTRATING working with your examples when the code hasn't been tested!!