Frequency counter using GPS 1PPS signal and temperature controlled 50MHz Base clock. Ported from F411 Frequency Counter.
Dependencies: QEI DRV8830 PID ADT7410 TextLCD Frq_cuntr_Nucleo-F746ZG RingBuffer
Fork of Frequency_Counter_w_GPS_1PPS by
Please refer following.
/users/kenjiArai/notebook/frequency-counters/
main.cpp
- Committer:
- kenjiArai
- Date:
- 2014-11-22
- Revision:
- 8:7b033903c8fb
- Parent:
- 7:0c09d29c4cf3
- Child:
- 9:e98e94ba17f9
File content as of revision 8:7b033903c8fb:
/* * mbed Application program / Frequency Counter with GPS 1PPS Compensation * * Copyright (c) 2014 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: October 18th, 2014 * Revised: Nobember 23rd, 2014 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define USE_COM // use Communication with PC(UART) // Include --------------------------------------------------------------------------------------- #include "mbed.h" #include "frq_cuntr_full.h" using namespace Frequency_counter; // Definition ------------------------------------------------------------------------------------ #ifdef USE_COM #define BAUD(x) pc.baud(x) #define GETC(x) pc.getc(x) #define PUTC(x) pc.putc(x) #define PRINTF(...) pc.printf(__VA_ARGS__) #define READABLE(x) pc.readable(x) #else #define BAUD(x) {;} #define GETC(x) {;} #define PUTC(x) {;} #define PRINTF(...) {;} #define READABLE(x) {;} #endif // Object ---------------------------------------------------------------------------------------- //DigitalOut led_gate(LED1); DigitalIn sw_01(PC_0); DigitalIn sw_10(PC_1); Serial pc(USBTX, USBRX); I2C i2cBus(PB_9,PB_8); // SDA, SCL // PC_6,PC_7 & PB6 use for Timer3 & 4 // PA_0,PA_1 & PB_10 use for Timer2 FRQ_CUNTR fc(PC_6, 1.0); // Input port & gate time[sec] // RAM ------------------------------------------------------------------------------------------- // ROM / Constant data --------------------------------------------------------------------------- // Function prototypes --------------------------------------------------------------------------- // Function prototypes --------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- // Control Program //------------------------------------------------------------------------------------------------- int main() { uint32_t counter_1pps = 0; uint32_t new_frequency = 0; BAUD(9600); // PA8 & PC9 uses for MCO_1 & MCO_2 -> Clock output for checking fc.port_mco1_mco2_set(2); // Clk/2 ->1/1(100MHz) cannot measure!! wait(1.0); fc.read_frequency_TIM2(1.0); fc.read_frequency_TIM3P4(1.0); PRINTF("\r\nFrequency Counter by JH1PJL created on "__DATE__"\r\n"); while(true) { while (fc.status_1pps() == 0) { ; } counter_1pps = fc.read_avarage_1pps(); while (fc.status_freq_update() == 0) { ; } new_frequency = fc.read_freq_data(); PRINTF("1PPS/ave = %9d , FREQUENCY = %9d\r\n", counter_1pps, new_frequency); } }