The tune reference MUX select inputs were connected to a version of the
tune mode signal synchronized to the tune_ref clock domain. This was an
oversight that would cause a 2-3 second delay after resetting the
counters when tuning against a 1PPS reference (because the synchronizer
block contains two flops clocked at 1 Hz). This was corrected and the
MUX now uses the system-synchronous tune_mode signal from the control
register in the Avalon-MM interface.
Renamed the tune_mode signals to include the clock domain (prefixed with
tune_ref_*).
Added ability for the Avalon-MM master to read back the control register
contents.
Updated tcxopps.stp SignalTap file with new signal names.
Error count calculation corrected to read "count - target" instead of
"target - count".
Added configuration for the width of the 1PPS pulse generated by the 10 MHz
reference (if using 10 MHz as a reference). Currently this is set to
1e3 x 10 MHz cycles, or 100 us.
- Updated NIOS code to comply with new VCTCXO Tamer reporting mechanisms.
- Using more #defines to define addresses and register bits.
- General cleanup.
- Now using pulse generator module instead of a process.
- When resetting the PPS counters, the reset holdoff time is now using
the VCTCXO clock instead of the NIOS system clock. The slower clock
will make timing closure easier and there are fewer bits required.
It may also have less variance between platforms (assuming the
VCTCXO remains 38.4 MHz).
- General cleanup and tweaks
Now using new devices.c helper functions: 'ppscal_reset_counters( false )'
and 'ppscal_enable_isr( true )' after processing the interrupt and
tweaking the VCTCXO Trim DAC. The new PPS Calibration ISR handles disabling
interrupts and clearing the existing counters so it does not need to happen
at the application level.
Added ppscal_reset_counters(bool), which allows application code to reset
the PPS calibration counters without having to know the register address
to do so.
Changed the ppscal_enable_isr(bool) function from being statically defined
and declared in devices.c to being declared in devices.h for use by application
code.
Modified the ppscal_isr() function to disable future interrupts from the PPS
calibration module, clear existing interrupts, and reset the PPS counters.
It is the job of the application to re-enable interrupts and to take the
counters out of reset.
When adjusting the trim DAC, there is a worst-case delay of 800 us when
transitioning from the minimum output to the maximum output supported
by the VCTCXO. This commit adds an 800 us delay between releasing the reset
and allowing the TCXO clock counter to increment.
Coarse algorithm rails the trim DAC to the min and max voltage supported by
the VCTCXO and creates a line based on the two points (x,y)=(error,DAC_count).
The slope is counts/Hz and the y-intercept is the DAC count with a theoretical
error of 0 Hz. After tuning the the y-intercept, a fine tuning method is used
in which the error is multiplied by a scaled version of the slope based on
the precision of the error (1s, 10s, 100s).
hdl: Changed the 10s error tolerance from 3 to 4.
Changed ppscal functions to use signed 64-bit integers (int64_t vs. uint64_t)
to be able to discern which direction the trim DAC needs to be adjusted.
Added a global variable to cache the trim DAC setting. This variable shall
only be updated during a call to 'devices.c:vctcxo_trim_dac_write()' and
is used by the VCTCXO tuning alorithm to make adjustments to the trim DAC
without having to read from the DAC.
Fixed bug in ppscal_read() that would only read the 1 second counter
regardless of the address passed into the function.
VCTCXO tuning algorithm in the main program loop actually does something
useful and is able to (over a very long period of time) tune the VCTCXO
to within 10 PPB. A proper PID-type algorithm should be implemented.
Added a VCTCXO model and a 16-bit DAC model for the bladeRF.
The mm_driver.vhd has a more reasonable frequency adjust state.
Simulations will need to be tweaked because they take way too
long. Perhaps best to not use the device models because the changes
are too small to see over a reasonable simulation time.
Interrupts used to fire every second if any of the three counters were off
target. Now, an interrupt will fire only when a new valid count appears
and the associated count value is off target. For example, if the 1 second
count is within the acceptable range, but the 10 second count is not, the
interrupt will only fire at 10 second intervals when the 10 second count
is updated.
Interrupts can only be cleared by the host processor by clearing the bit
specified in the memory map.
Error tolerance is now a 64-bit signed number as opposed to a 'natural',
which is limited to 32 bits.