Revision aa4a6b66

b/host/docs/usrp2.rst
205 205
::
206 206

  
207 207
    addr=192.168.10.2, recv_buff_size=100e6
208

  
209
------------------------------------------------------------------------
210
Hardware setup notes
211
------------------------------------------------------------------------
212

  
213
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
214
Ref Clock - 10MHz
215
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
216
Using an external 10MHz reference clock requires a signal level between +5dBm and +20dBm at 10MHz applied to the Ref Clock SMA port on the front panel.
217

  
218

  
219
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
220
PPS - Pulse Per Second
221
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
222
Using a PPS signal for timestamp synchronization requires a 5Vpp square wave signal
b/host/examples/CMakeLists.txt
28 28
ADD_EXECUTABLE(tx_waveforms tx_waveforms.cpp)
29 29
TARGET_LINK_LIBRARIES(tx_waveforms uhd)
30 30

  
31
ADD_EXECUTABLE(pps_test pps_test.cpp)
32
TARGET_LINK_LIBRARIES(pps_test uhd)
33

  
31 34
INSTALL(TARGETS
32 35
    benchmark_rx_rate
33 36
    rx_timed_samples
34 37
    tx_timed_samples
35 38
    tx_waveforms
39
    pps_test
36 40
    RUNTIME DESTINATION ${PKG_DATA_DIR}/examples
37 41
)
b/host/examples/pps_test.cpp
1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

  
18
#include <uhd/utils/thread_priority.hpp>
19
#include <uhd/utils/safe_main.hpp>
20
#include <uhd/usrp/simple_usrp.hpp>
21
#include <boost/program_options.hpp>
22
#include <boost/format.hpp>
23
#include <boost/thread.hpp>
24
#include <iostream>
25
#include <complex>
26

  
27
namespace po = boost::program_options;
28

  
29
int UHD_SAFE_MAIN(int argc, char *argv[]){
30
    uhd::set_thread_priority_safe();
31

  
32
    //variables to be set by po
33
    std::string args;
34
    float seconds;
35

  
36
    //setup the program options
37
    po::options_description desc("Allowed options");
38
    desc.add_options()
39
        ("help", "help message")
40
        ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
41
    ;
42
    po::variables_map vm;
43
    po::store(po::parse_command_line(argc, argv, desc), vm);
44
    po::notify(vm);
45

  
46
    //print the help message
47
    if (vm.count("help")){
48
        std::cout << boost::format("UHD PPS Test %s") % desc << std::endl;
49
        return ~0;
50
    }
51

  
52
    //create a usrp device
53
    std::cout << std::endl;
54
    std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
55
    uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
56
    uhd::device::sptr dev = sdev->get_device();
57
    std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
58

  
59
    //set a known time value
60
    std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl;
61
    sdev->set_time_now(uhd::time_spec_t(100.0));
62
    boost::this_thread::sleep(boost::posix_time::seconds(1));
63
    std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_full_secs()) << std::endl;
64

  
65
    //store the time to see if PPS resets it
66
    seconds = sdev->get_time_now().get_full_secs();
67

  
68
    //set a known time at next PPS, check that time increments
69
    uhd::time_spec_t time_spec = uhd::time_spec_t(0.0);
70
    std::cout << "Set time to known value (0.0) at next pps:" << std::endl;
71
    sdev->set_time_next_pps(time_spec);
72
    boost::this_thread::sleep(boost::posix_time::seconds(1));
73
    std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_full_secs()) << std::endl;
74

  
75
    //finished
76
    if (seconds > sdev->get_time_now().get_full_secs()){
77
        std::cout << std::endl << "Success!" << std::endl << std::endl;
78
        return 0;
79
    } else {
80
        std::cout << std::endl << "Failed!" << std::endl << std::endl 
81
            << "If you expected PPS to work:" << std::endl
82
            << "\tsee Device App Notes for PPS level information"
83
            << std::endl << std::endl;
84
        return -1;
85
    }
86
}

Also available in: Unified diff