ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

PwmOut broken on LPC11UXX #278

Closed neilt6 closed 10 years ago

neilt6 commented 10 years ago

Creating a PwmOut object using P0_8, and setting the period to 2µs (500kHz) produces an incorrect waveform running at ~33kHz. This code worked on a previous version of the mbed library, leading me to believe it was broken 4 months ago as part of https://github.com/mbedmicro/mbed/commit/a3465b5eacb4d383e742abfecedeadbd637b2b24.

neilt6 commented 10 years ago

Picture of the waveform produced by setting the period to 2µs, and the duty cycle to 0.9: pwmout bug

xiongyihui commented 10 years ago

I forgot to clear the prescaler register when the prescaler is not needed. Originally, P_8 (PWM of 16bit timer) can't correctly generate 20m PWM, so the prescaler is added.

neilt6 commented 10 years ago

Should be an easy fix then?