8 years, 8 months ago.

It would be very helpful to get the source code (CPP) for the FRDM-K22F demo code

The demo code got erased from my FRDM-K22F eval board. It would be very useful to see the source code of the demo, It's easier to see how someone else did something that trying to get it to work from the datasheets.

In particular, I'm having difficulty getting the PWM to work. The PWM demo code that's posted on the forum doesn't seem to work.

PwmOut_Example1

#include "mbed.h"
 
PwmOut led(PTA1);  // changed this from LED2 to specifically address the red LED on the demo board
 
int main() {
    // specify period first, then everything else
    led.period(4.0f);  // 4 second period
    led.write(0.50f);  // 50% duty cycle
    while(1);          // led flashing
}

As someone else posted, it only works with a period of 50 ms. I wanna see how the demo code was written.

Additional info on this question - demo code. From AN5040, the demo code should be available at <install_dir>/demos/<demo_name>/<toolchain>/<board_nam

Unfortunately there's no \demo directory in my install of KDS_3.0.0. Also, i've been using MBED, not the KSDK

posted by Bob Pospick 27 Aug 2015

1 Answer

8 years, 8 months ago.

The maximum PWM period for the K22F is something like what you mention (50ms, if it even reaches that). Smaller values work, larger don't. It can be extended a bit (FastPWM lib does this, to something like 0.1-0.2 seconds max iirc), more than that simply is not possible (unless you start slowing down the system clock).

If that demo has a larger period it simply is toggling GPIO.

Accepted Answer