9 years, 8 months ago.

How generate a 1M Hz clock with interrupt ?

I want to create a square signal at 1M Hz. I try with timer and it's not possible to generate not more than 30k Hz.

Help me please !!!!

1 Answer

9 years, 8 months ago.

Just use PWM to create it, much more efficient than using timer interrupts.

The default mbed PWM code won't be able to do that for the KL25z, however if you use this library: http://developer.mbed.org/users/Sissors/code/FastPWM/, you can simply create output with 1us period and 50% duty cycle.

Accepted Answer

Thanks for your answer but how to put my PWM using interrupt ?

posted by Clément Csech 03 Mar 2015

You don't use an interrupt, you just set the PWM to create a 1MHz clock continiously. And you disable/enable it whenever you want.

posted by Erik - 03 Mar 2015