Creates square-wave frequency output on pin p22. Custom frequency between 1Hz and 48 MHz. (LPC 1768)
Creates square-wave frequency output on pin22 with custom frequency.
Tested for frequencies from 1Hz to 48MHz. The accuracy depends heavily on the frequency - at 12, 24, 48 MHz the frequency deviation is less than 1%, but at 20 MHz it is about 20%.
Uses Library FastPWM ( http://mbed.org/users/Sissors/code/FastPWM/ ). For LPC 1768.
How to use this Library:
#include "mbed.h" #include "PwmOscillator.h" PwmOscillator oscillator; DigitalOut led1(LED1); int main() { oscillator.initWithFrequency(8000000); // initialize oscillator instance (pin p22) with custom frequency, here: 8MHz led1=1; // optional: indicator LED shows that oscillator is running oscillator.start(); // start oscillator wait(5); // optional: oscillator is running 5 seconds oscillator.stop(); // stop oscillator led1=0; }
History
Added #definition to prevent multiple includes
2012-12-14, by geotec [Fri, 14 Dec 2012 14:47:22 +0000] rev 2
Added #definition to prevent multiple includes
Improved documentation
2012-12-14, by geotec [Fri, 14 Dec 2012 14:39:48 +0000] rev 1
Improved documentation
Initial commit
2012-12-14, by geotec [Fri, 14 Dec 2012 14:34:22 +0000] rev 0
Initial commit