![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Frequency counter using LPC1768 hardware counter, tested up-to 11MHz forked from https://developer.mbed.org/users/mio/code/5MHzOSC/
Fork of 5MHzOSC by
Diff: main.cpp
- Revision:
- 3:603f4efe3985
- Parent:
- 2:bff82681a822
- Child:
- 4:e7d16ef216d4
diff -r bff82681a822 -r 603f4efe3985 main.cpp --- a/main.cpp Sun May 26 05:42:36 2013 +0000 +++ b/main.cpp Tue Jun 18 14:15:38 2013 +0000 @@ -2,7 +2,7 @@ // CLOCK OUT to PWM1[6] Sample with Freq Counter using Cap2.0 // For LPC1768-mbed // -// Reference: 5MHz Clock Out Code and Comment - http://mbed.org/forum/mbed/topic/733/ +// Reference: 1MHz Clock Out Code and Comment - http://mbed.org/forum/mbed/topic/733/ // // !! To Self Measurement Output Clock, Connect p21 <-> p30 with jumper wire. // @@ -45,13 +45,13 @@ LPC_SC->PCLKSEL0 &= ~(0x3 << 12); LPC_SC->PCLKSEL0 |= (1 << 12); // 2)Set peripheral clock divider to /1, i.e. system clock LPC_PWM1->MR0 = div - 1; // 3)Match Register 0 is shared period counter for all PWM1 - LPC_PWM1->MR6 = 9; // 3)Pin 21 is PWM1[6], so Match Register 6 + LPC_PWM1->MR6 = (div + 1)>> 1; // LPC_PWM1->LER |= 1; // 4)Start updating at next period start LPC_PWM1->TCR = (1 << 0) || (1 << 3); // 5)Enable counter and PWM } int main() { - PWM6_SETCLK(96) ; // Outout mbed's "PWM6" pin to 96MHZ/19 = 5.052MHz (Approx) + PWM6_SETCLK(96*5) ; // Outout mbed's "PWM6" pin to 96MHZ/19 = 5.052MHz (Approx) P30_INIT_CTR(); while(1){ P30_RESET_CTR();