LPC1000 and PWM audio not possible?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by madid87 on Wed Aug 01 08:22:35 MST 2012
Hello everyone.

I'm trying to play 8-bit uncompressed .wav music via PWM on LPC1114.
The problem I have is that PWM match registers are not double buffered. Because of it there are glitches present in the PWM output when duty-cycle is varied.

- PWM period is set via MR3=255.
- current duty cycle is set to, i.e. MR0=190;
- new duty cycle should be 90, i.e. MR0=90.

If the timer is somewhere between these values (new and old duty cycle) when the new duty cycle is written the output will never go high because no match will occur in that PWM period. This causes huge distortion in my audio signal.

I'm sure some of you are familiar with this problem. Is there a easy work-around? I have tried to determine the safe time window for writing the new value but it looks very difficult because PWM clock frequency is running at maximum 48MHz and the CPU cannot keep track of the current timer value accurately enough.

Thank you.