The OPWMB mode have to use other counter bus (channels 16 or 23). The OPWFMB mode does not...
Here is basic code for OPWFMB mode...
void initEMIOS(void) {
EMIOS_1.MCR.B.GPRE= 63; /* Divide 64 MHz sysclk by 63+1 = 64 for 1MHz eMIOS clk*/
EMIOS_1.MCR.B.ETB = 0; /* External time base is disabled; */
EMIOS_1.MCR.B.GPREN = 1; /* Enable eMIOS clock */
EMIOS_1.MCR.B.GTBE = 1; /* Enable global time base */
EMIOS_1.MCR.B.FRZ = 1; /* Enable stopping channels when in debug mode */
}
void initEMIOSch(void) { /* EMIOS CH : Output Pulse Width & Freq Modulation*/
/* Provide 10KHz output (100usec period) */
/* Input clock is eMIOS clk of 1MHz (1 usec period)*/
EMIOS_1.CH[17].CBDR.R = 99; /* Period = 1 usec x (99+1) = 100 usec, 10KHz*/
EMIOS_1.CH[17].CADR.R = 30; /* Duty cycle */
EMIOS_1.CH[17].CCR.B.UCPRE = 0; /* Channel counter uses divide by (0+1) prescaler */
EMIOS_1.CH[17].CCR.B.UCPEN = 1; /* Channel counter's prescaler is loaded & enabled*/
EMIOS_1.CH[17].CCR.B.EDPOL = 1; /* Polarity is active high */
EMIOS_1.CH[17].CCR.B.MODE= 0x58; /* Mode= 0PWFMB */
}
BR, Petr