Clock generator @ 145 MHz and 7 mhz
Fork of Check_Si5351A_Clock_generator by
Diff: si5351a_check.cpp
- Revision:
- 3:92f31b23fb0b
- Parent:
- 2:73d79424daa5
- Child:
- 4:5981cf106502
--- a/si5351a_check.cpp Thu Jan 05 13:23:11 2017 +0000 +++ b/si5351a_check.cpp Fri Jan 06 14:09:18 2017 +0000 @@ -8,7 +8,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: December 28th, 2016 - * Revised: January 5th, 2017 + * Revised: January 6th, 2017 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF @@ -32,6 +32,9 @@ I2C i2c(I2C_SDA, I2C_SCL); // communication with Si5351A SI5351A clk(i2c, 25000000UL); // base clock = 25.0MHz +// RAM ------------------------------------------------------------------------ +bool one_char = false; + //------------------------------------------------------------------------------ // Control Program //------------------------------------------------------------------------------ @@ -65,6 +68,8 @@ put_rn(); PRINTF("c - Show current configration"); put_rn(); + PRINTF("p - Compensation"); + put_rn(); PRINTF("r - Show current resisters"); put_rn(); PRINTF("x - Go to special command"); @@ -223,6 +228,7 @@ // test7 CLK0: set desired center freq. then shift +/- range //-------------------------------------------------------------- case '7' : + one_char = true; clk.all_reset(); PRINTF("CLK0 %s", msg0); put_rn(); @@ -281,6 +287,7 @@ break; } } + one_char = false; break; //-------------------------------------------------------------- // All clear alll registers @@ -297,6 +304,28 @@ //put_rn(); break; //-------------------------------------------------------------- + // Compensation + //-------------------------------------------------------------- + case 'p' : + clk.set_frequency(0, 25000000); // Set CLK0=10MHz + PRINTF( + "Please measure Clock0 output frequency (aound 25MHz)\r\n"); + PRINTF("Enter your mesured data = "); + ptr = linebuf; + get_line(ptr, buf_size); + if (xatoi(&ptr,&f)){ + if (f < 0){ + PUTC('?'); + break; + } + PRINTF("\r%u [Hz]\r\n", f); + clk.f_compensation(25000000, f); + clk.debug_current_config(); + } else { + PUTC('?'); + } + break; + //-------------------------------------------------------------- // Show resisters //-------------------------------------------------------------- case 'r' : @@ -416,7 +445,7 @@ } } #endif - + void special_command(void) { PRINTF("Not impliment yet"); @@ -515,8 +544,13 @@ if (((uint8_t)c >= ' ') && (idx < len - 1)) { buff[idx++] = c; PUTC(c); + // Special control + if (one_char == true){ + if ((c == 'p') || (c == 'm')){ break;} + } } } buff[idx] = 0; PUTC('\n'); } +