sorry for creating a new thread, but I could not figure out how to attach a file to an already submitted thread. The previous thread can be deleted. So here is the original thread together with a minimal IAR project.
In our application occurs a problem when using the PWM in standard mode. The PWM device sometimes does not update the compare registers when writing '1' to PWMCON0.LCOMP. I can reproduce the problem with the following setup:
- deactivation of the watchdog timer
- changing the clock configuration: CLKSYSDIV.DIV2EN=0, CLKDIS.DISPWMCLK=0, CLKCON0.CD=3, CLKCON1.PWMCD=0
- using pin P1.2 as PWM0 output by setting GP1CON.CON2='01'b
- setup of the PWM device: PWMCON0=0x0400, PWM0COM0=0x0300, PWM0COM1=0x0100, PWM0LEN=0x0300
- starting the PWM device: PWMCON0.LCOMP='1', PWMCON0.ENABLE='1'
This setup starts the PWM device correctly, I can modify the compare registers and can load the register by setting PWMCON0.LCOMP='1'.
However, if I alter the PWMCD clock divider of the CLKCON1 register, e.g., CLKCON1.PWMCD='111'b, then loading a new compare ragister via PWMCON0.LCOMP does not take effect. The new compare register values are only accepted when the PWM output is disabled and enabled again: PWMCON0.ENABLE='0' --> PWMCON0.ENABLE='1', see attached example project.
Testing two different ADuCM360 devices with the aforementioned setup, I could figure out the following behaviour:
- The compare registers can be loaded correctly (by setting PWMCON0.LCOMP='1') if CLKCON0.CD is greater than CLKCON1.PWMCD. (CLKCON0.CD > CLKCON1.PWMCD means that the clock frequency of the the PWM counter is greater than the bus frequency)
- The laoding of the compare register is severely limited if CLKCON0.CD <= CLKCON1.PWMCD. Severly limited means, for some configurations it never works and for some configuration it works sporadically.
Is this a known issue, or do we configure the device not correctly? Does anyone has the same problem?