Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 00002 #include "mbed.h" 00003 #include "Timer2.h" 00004 #include "Timer3.h" 00005 /* 00006 Connect P8 (MAT2.0) to P16 (CAP3.1) 00007 Connect external input on P15 (CAP3.0) to PWM output on P26 00008 */ 00009 Serial pc(USBTX, USBRX); // tx, rx 00010 DigitalOut out1(p5), out2(p6); 00011 PwmOut pw(p26); 00012 00013 int done; 00014 void Timer3Isr(int count) 00015 { 00016 pc.printf("count=%d\n\r", count); 00017 LPC_TIM2->TCR = 2; // Disable Timer2 00018 done = 1; 00019 } 00020 00021 void Timer2Isr(void) 00022 { 00023 out1 = !out1; 00024 } 00025 00026 int main(void) 00027 { 00028 int prescale; // Units are 0.1 second. 00029 00030 out1 = 0; 00031 out2 = 0; 00032 pw.period_us(10); 00033 pw.write(0.5); 00034 Timer3_init(Timer3Isr); 00035 Timer2_init(Timer2Isr); 00036 while(1) 00037 { 00038 pc.printf("PS: "); 00039 pc.scanf("%d", &prescale); // Interval is <prescale>+1 * 0.1 second. 00040 pc.printf("%d\n\r", prescale); 00041 done = 0; 00042 Timer2_start(prescale); 00043 while (!done) 00044 out2 = !out2; 00045 } 00046 } 00047 00048
Generated on Sun Jul 24 2022 14:19:45 by
1.7.2