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.
ClockCounter Class Reference
ClockCounter class Counts signal transitions on p30(CAP2.0) or p29(CAP2.1) for LPC1768 target. More...
#include <lib_ClockCounter.h>
| Public Member Functions | |
| ClockCounter (PinName PIN_CAP2=p30, edgeDetection EDGE=RISING) | |
| Create an ClockCounter instance. | |
| void | setPin (PinName PIN_CAP2, edgeDetection EDGE=RISING) | 
| Select an ClockCounter instance. | |
| void | startCount (void) | 
| Start the signal transition count. | |
| int | stopCount (void) | 
| Stop and Get the signal transition count. | |
| int | getCount (int period=1000000) | 
| Get the signal transition count during period. | |
| PinName | getPin (void) | 
| Get the selected input PIN_CAP2 on started signal transition count. | |
Detailed Description
ClockCounter class Counts signal transitions on p30(CAP2.0) or p29(CAP2.1) for LPC1768 target.
Can detecte rising, falling or both signal edge. Return the signal edge count during a period in seconds. In theory (Shannon's theorem) input signal frequency can up to 48 MHz with 96 MHz CCLK. But only tested with frequencys up to 20 MHz and it work.
Definition at line 42 of file lib_ClockCounter.h.
Constructor & Destructor Documentation
| ClockCounter | ( | PinName | PIN_CAP2 = p30, | 
| edgeDetection | EDGE = RISING | ||
| ) | 
Create an ClockCounter instance.
Mbed Library Clock Counter Hardware pulse counter with TIMER2 (CAP2.0 or CAP2.1) on Mbed LPC1768.
Configure LPC1768 TIMER2 with capture input PIN_CAP2 and detecte transition EDGE.
- Parameters:
- 
  PIN_CAP2 can be p30(CAP2.0) or p29(CAP2.1), default is p30(CAP2.0). EDGE can be RISING, FALLING, BOTH, default is RISING. 
Counts signal transitions on p30(CAP2.0) or p29(CAP2.1) for LPC1768 target. Can detecte rising, falling or both signal edge. Return the signal edge count during a period in seconds. In theory (Shannon's theorem) input signal frequency can up to 48 MHz with 96 MHz CCLK. But only tested with frequencys up to 20 MHz and it work.
Example :
#include "mbed.h" #include "lib_ClockCounter.h" Serial pc(USBTX, USBRX); ClockCounter Frequency; int main() { while(1) pc.printf("Frequency = %d Hz\r\n", Frequency.getCount()); }
Definition at line 28 of file lib_ClockCounter.cpp.
Member Function Documentation
| int getCount | ( | int | period = 1000000) | 
Get the signal transition count during period.
- Parameters:
- 
  period default is 1000000 microsecond. 
Definition at line 92 of file lib_ClockCounter.cpp.
| PinName getPin | ( | void | ) | 
Get the selected input PIN_CAP2 on started signal transition count.
Definition at line 102 of file lib_ClockCounter.cpp.
| void setPin | ( | PinName | PIN_CAP2, | 
| edgeDetection | EDGE = RISING | ||
| ) | 
Select an ClockCounter instance.
Configure LPC1768 TIMER2 with capture input PIN_CAP2 and detecte transition EDGE.
- Parameters:
- 
  PIN_CAP2 can be p30(CAP2.0) or p29(CAP2.1). EDGE can be RISING, FALLING, BOTH, default is RISING. 
Definition at line 53 of file lib_ClockCounter.cpp.
| void startCount | ( | void | ) | 
Start the signal transition count.
Definition at line 77 of file lib_ClockCounter.cpp.
| int stopCount | ( | void | ) | 
Stop and Get the signal transition count.
Definition at line 84 of file lib_ClockCounter.cpp.
Generated on Fri Jul 15 2022 07:54:03 by
 1.7.2
 1.7.2