I select the ch0 to generate PWM signal, PWM period = 100us, PWM duty cycle = 10%, the following code is configuration:
EMIOS_0.MCR.R = 0x10003f00; /* Enable global prescaler, divider ratio = 64, clock = fsys / 64 = 1MHz */
EMIOS_0.CH.CADR.R = 0;
EMIOS_0.CH.CBDR.R = 10;
EMIOS_0.CH.CCR.R = 0x20206e0; /* Select internal counter */
EMIOS_0.CH.CSR.R = 0x80008001;
EMIOS_0.MCR.B.GPREN = 1; /* Start eMIOS */
INTC_InstallINTCInterruptHandler(emios_ch1_isr, 141, 2); /* eMIOS channel 1 priority: 2 */
INTC.CPR.R = 0x0;
if (EMIOS_0.CH.CSR.B.FLAG == 1)
EMIOS_0.CH.CADR.R += 100;
EMIOS_0.CH.CBDR.R += 100;
EMIOS_0.CH.CSR.B.FLAG = 1;
But the wave is wrong, the positive pulse width is 10us and the negative pulse width is 65ms. It seems that EMIOS_0.CH.CADR.R and EMIOS_0.CH.CBDR.R can't be updated. Is anything wrong with my configuration?
Please guide me to solve it, thanks!
in OPWMB mode, you selected, an external counter driven in MCB Up mode must be selected from one of the
counter buses. So add another channel for MCB up mode if you want to use OPWMB.
Or select OPWFMB for channel 0 and use it accordingly.