The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Issue: mbed or KL25Z PwmOut (Closed: Invalid)

Hi I need a 2Hz pwm.My code is like this but gives a 16hz pwm: PwmOut Lamp(PTD4); Lamp.period(0.5); Lamp=0.5; set duty cycle to 50%

Is this a bug or misconfiguration?

Thanks

1 comment:

14 Feb 2014

This is more a question than an issue. But the KL25Z has a limitted prescaler for the PwmOut. Something like 16Hz is indeed the lowest frequency it can reach, 2Hz is not possible. Using http://mbed.org/users/Sissors/code/FastPWM/ you can get it a bit lower, IIRC a factor 2, since contrary to the mbed lib it can change the prescaler. But the prescaler simply cannot go further than that.

That said, for a 2Hz PWM you don't really need a PWM output, you can also simply use a ticker and then in software do the toggling.