{"action":"created","comment":{"url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/comments/78386376","id":78386376,"diff_hunk":"@@ -1513,7 +1457,37 @@ void APS2::setup_VCXO() {\n   write_SPI(msg);\n }\n \n-void APS2::setup_DAC(const int &dac)\n+void APS2::align_DAC_clock(int dac) {\n+  // toggle DAC clocks until DATACLK_OUT comes up \"aligned\" to system 600\n+  const vector<uint32_t> PHASE_COUNT_ADDR = {PHASE_COUNT_A_ADDR,\n+                                             PHASE_COUNT_B_ADDR};\n+  // Loop over number of tries\n+  for (int ct = 0; ct < MAX_DAC_CLOCK_PHASE_TEST_TRIES; ct++) {\n+    // register returns a value in [0, 0xffff]. Re-interpret as portion of\n+    // circle\n+    auto dac_clk_phase =\n+        static_cast<double>(read_memory(PHASE_COUNT_ADDR[dac], 1)[0]) /\n+        (0xffff);\n+\n+    FILE_LOG(logDEBUG1) << ipAddr_ << \" measured DAC \"\n+                        << ((dac == 0) ? \"A\" : \"B\") << \" clock phase of \"\n+                        << dac_clk_phase;\n+\n+    if (dac_clk_phase < 0.5) {\n+      // done with this channel\n+      return;\n+    } else {\n+      // toggle DAC clock to try and get different phase\n+      toggle_DAC_clock(dac);\n+      // wait for phase count to run\n+      std::this_thread::sleep_for(std::chrono::milliseconds(1));\n+    }\n+  }\n+  // if we got here then we never aligned\n+  FILE_LOG(logERROR) << ipAddr_ << \" failed to align DAC \" << dac;","path":"src/lib/APS2.cpp","position":227,"original_position":227,"commit_id":"cbc6a7f4a2a9991a38f0b8272d209c951eeecb4b","original_commit_id":"882d8c865ba8f98d066fd1f23e34927d78870343","user":{"login":"blakejohnson","id":866695,"avatar_url":"https://avatars.githubusercontent.com/u/866695?v=3","gravatar_id":"","url":"https://api.github.com/users/blakejohnson","html_url":"https://github.com/blakejohnson","followers_url":"https://api.github.com/users/blakejohnson/followers","following_url":"https://api.github.com/users/blakejohnson/following{/other_user}","gists_url":"https://api.github.com/users/blakejohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/blakejohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blakejohnson/subscriptions","organizations_url":"https://api.github.com/users/blakejohnson/orgs","repos_url":"https://api.github.com/users/blakejohnson/repos","events_url":"https://api.github.com/users/blakejohnson/events{/privacy}","received_events_url":"https://api.github.com/users/blakejohnson/received_events","type":"User","site_admin":false},"body":"Sure, makes sense.","created_at":"2016-09-12T14:44:41Z","updated_at":"2016-09-12T14:44:41Z","html_url":"https://github.com/BBN-Q/libaps2/pull/85#discussion_r78386376","pull_request_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/comments/78386376"},"html":{"href":"https://github.com/BBN-Q/libaps2/pull/85#discussion_r78386376"},"pull_request":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85","id":83325315,"html_url":"https://github.com/BBN-Q/libaps2/pull/85","diff_url":"https://github.com/BBN-Q/libaps2/pull/85.diff","patch_url":"https://github.com/BBN-Q/libaps2/pull/85.patch","issue_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/85","number":85,"state":"closed","locked":false,"title":"DAC bitslipping and no DAC FIFOs","user":{"login":"caryan","id":1385106,"avatar_url":"https://avatars.githubusercontent.com/u/1385106?v=3","gravatar_id":"","url":"https://api.github.com/users/caryan","html_url":"https://github.com/caryan","followers_url":"https://api.github.com/users/caryan/followers","following_url":"https://api.github.com/users/caryan/following{/other_user}","gists_url":"https://api.github.com/users/caryan/gists{/gist_id}","starred_url":"https://api.github.com/users/caryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caryan/subscriptions","organizations_url":"https://api.github.com/users/caryan/orgs","repos_url":"https://api.github.com/users/caryan/repos","events_url":"https://api.github.com/users/caryan/events{/privacy}","received_events_url":"https://api.github.com/users/caryan/received_events","type":"User","site_admin":false},"body":"This passes DAC BIST in 7 units over three different boxes but I'm still a little worried.","created_at":"2016-08-30T18:46:27Z","updated_at":"2016-09-12T14:44:41Z","closed_at":"2016-09-12T14:15:44Z","merged_at":"2016-09-12T14:15:44Z","merge_commit_sha":"c41d40839928b81908c4d114af004e7f1a5ad9bf","assignee":{"login":"blakejohnson","id":866695,"avatar_url":"https://avatars.githubusercontent.com/u/866695?v=3","gravatar_id":"","url":"https://api.github.com/users/blakejohnson","html_url":"https://github.com/blakejohnson","followers_url":"https://api.github.com/users/blakejohnson/followers","following_url":"https://api.github.com/users/blakejohnson/following{/other_user}","gists_url":"https://api.github.com/users/blakejohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/blakejohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blakejohnson/subscriptions","organizations_url":"https://api.github.com/users/blakejohnson/orgs","repos_url":"https://api.github.com/users/blakejohnson/repos","events_url":"https://api.github.com/users/blakejohnson/events{/privacy}","received_events_url":"https://api.github.com/users/blakejohnson/received_events","type":"User","site_admin":false},"assignees":[{"login":"blakejohnson","id":866695,"avatar_url":"https://avatars.githubusercontent.com/u/866695?v=3","gravatar_id":"","url":"https://api.github.com/users/blakejohnson","html_url":"https://github.com/blakejohnson","followers_url":"https://api.github.com/users/blakejohnson/followers","following_url":"https://api.github.com/users/blakejohnson/following{/other_user}","gists_url":"https://api.github.com/users/blakejohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/blakejohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blakejohnson/subscriptions","organizations_url":"https://api.github.com/users/blakejohnson/orgs","repos_url":"https://api.github.com/users/blakejohnson/repos","events_url":"https://api.github.com/users/blakejohnson/events{/privacy}","received_events_url":"https://api.github.com/users/blakejohnson/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85/commits","review_comments_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85/comments","review_comment_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/85/comments","statuses_url":"https://api.github.com/repos/BBN-Q/libaps2/statuses/cbc6a7f4a2a9991a38f0b8272d209c951eeecb4b","head":{"label":"BBN-Q:dac-alignment","ref":"dac-alignment","sha":"cbc6a7f4a2a9991a38f0b8272d209c951eeecb4b","user":{"login":"BBN-Q","id":1385056,"avatar_url":"https://avatars.githubusercontent.com/u/1385056?v=3","gravatar_id":"","url":"https://api.github.com/users/BBN-Q","html_url":"https://github.com/BBN-Q","followers_url":"https://api.github.com/users/BBN-Q/followers","following_url":"https://api.github.com/users/BBN-Q/following{/other_user}","gists_url":"https://api.github.com/users/BBN-Q/gists{/gist_id}","starred_url":"https://api.github.com/users/BBN-Q/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBN-Q/subscriptions","organizations_url":"https://api.github.com/users/BBN-Q/orgs","repos_url":"https://api.github.com/users/BBN-Q/repos","events_url":"https://api.github.com/users/BBN-Q/events{/privacy}","received_events_url":"https://api.github.com/users/BBN-Q/received_events","type":"Organization","site_admin":false},"repo":{"id":21963462,"name":"libaps2","full_name":"BBN-Q/libaps2","owner":{"login":"BBN-Q","id":1385056,"avatar_url":"https://avatars.githubusercontent.com/u/1385056?v=3","gravatar_id":"","url":"https://api.github.com/users/BBN-Q","html_url":"https://github.com/BBN-Q","followers_url":"https://api.github.com/users/BBN-Q/followers","following_url":"https://api.github.com/users/BBN-Q/following{/other_user}","gists_url":"https://api.github.com/users/BBN-Q/gists{/gist_id}","starred_url":"https://api.github.com/users/BBN-Q/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBN-Q/subscriptions","organizations_url":"https://api.github.com/users/BBN-Q/orgs","repos_url":"https://api.github.com/users/BBN-Q/repos","events_url":"https://api.github.com/users/BBN-Q/events{/privacy}","received_events_url":"https://api.github.com/users/BBN-Q/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BBN-Q/libaps2","description":"C/C++ driver for BBN APSv2","fork":false,"url":"https://api.github.com/repos/BBN-Q/libaps2","forks_url":"https://api.github.com/repos/BBN-Q/libaps2/forks","keys_url":"https://api.github.com/repos/BBN-Q/libaps2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BBN-Q/libaps2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BBN-Q/libaps2/teams","hooks_url":"https://api.github.com/repos/BBN-Q/libaps2/hooks","issue_events_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/events{/number}","events_url":"https://api.github.com/repos/BBN-Q/libaps2/events","assignees_url":"https://api.github.com/repos/BBN-Q/libaps2/assignees{/user}","branches_url":"https://api.github.com/repos/BBN-Q/libaps2/branches{/branch}","tags_url":"https://api.github.com/repos/BBN-Q/libaps2/tags","blobs_url":"https://api.github.com/repos/BBN-Q/libaps2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BBN-Q/libaps2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BBN-Q/libaps2/git/refs{/sha}","trees_url":"https://api.github.com/repos/BBN-Q/libaps2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BBN-Q/libaps2/statuses/{sha}","languages_url":"https://api.github.com/repos/BBN-Q/libaps2/languages","stargazers_url":"https://api.github.com/repos/BBN-Q/libaps2/stargazers","contributors_url":"https://api.github.com/repos/BBN-Q/libaps2/contributors","subscribers_url":"https://api.github.com/repos/BBN-Q/libaps2/subscribers","subscription_url":"https://api.github.com/repos/BBN-Q/libaps2/subscription","commits_url":"https://api.github.com/repos/BBN-Q/libaps2/commits{/sha}","git_commits_url":"https://api.github.com/repos/BBN-Q/libaps2/git/commits{/sha}","comments_url":"https://api.github.com/repos/BBN-Q/libaps2/comments{/number}","issue_comment_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/comments{/number}","contents_url":"https://api.github.com/repos/BBN-Q/libaps2/contents/{+path}","compare_url":"https://api.github.com/repos/BBN-Q/libaps2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BBN-Q/libaps2/merges","archive_url":"https://api.github.com/repos/BBN-Q/libaps2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BBN-Q/libaps2/downloads","issues_url":"https://api.github.com/repos/BBN-Q/libaps2/issues{/number}","pulls_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls{/number}","milestones_url":"https://api.github.com/repos/BBN-Q/libaps2/milestones{/number}","notifications_url":"https://api.github.com/repos/BBN-Q/libaps2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BBN-Q/libaps2/labels{/name}","releases_url":"https://api.github.com/repos/BBN-Q/libaps2/releases{/id}","deployments_url":"https://api.github.com/repos/BBN-Q/libaps2/deployments","created_at":"2014-07-18T01:25:57Z","updated_at":"2016-04-30T13:15:40Z","pushed_at":"2016-09-12T14:16:03Z","git_url":"git://github.com/BBN-Q/libaps2.git","ssh_url":"git@github.com:BBN-Q/libaps2.git","clone_url":"https://github.com/BBN-Q/libaps2.git","svn_url":"https://github.com/BBN-Q/libaps2","homepage":null,"size":4567,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":2,"default_branch":"master"}},"base":{"label":"BBN-Q:master","ref":"master","sha":"3d41e6bd4246692d33cb441c6e5a77ca0678e200","user":{"login":"BBN-Q","id":1385056,"avatar_url":"https://avatars.githubusercontent.com/u/1385056?v=3","gravatar_id":"","url":"https://api.github.com/users/BBN-Q","html_url":"https://github.com/BBN-Q","followers_url":"https://api.github.com/users/BBN-Q/followers","following_url":"https://api.github.com/users/BBN-Q/following{/other_user}","gists_url":"https://api.github.com/users/BBN-Q/gists{/gist_id}","starred_url":"https://api.github.com/users/BBN-Q/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBN-Q/subscriptions","organizations_url":"https://api.github.com/users/BBN-Q/orgs","repos_url":"https://api.github.com/users/BBN-Q/repos","events_url":"https://api.github.com/users/BBN-Q/events{/privacy}","received_events_url":"https://api.github.com/users/BBN-Q/received_events","type":"Organization","site_admin":false},"repo":{"id":21963462,"name":"libaps2","full_name":"BBN-Q/libaps2","owner":{"login":"BBN-Q","id":1385056,"avatar_url":"https://avatars.githubusercontent.com/u/1385056?v=3","gravatar_id":"","url":"https://api.github.com/users/BBN-Q","html_url":"https://github.com/BBN-Q","followers_url":"https://api.github.com/users/BBN-Q/followers","following_url":"https://api.github.com/users/BBN-Q/following{/other_user}","gists_url":"https://api.github.com/users/BBN-Q/gists{/gist_id}","starred_url":"https://api.github.com/users/BBN-Q/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBN-Q/subscriptions","organizations_url":"https://api.github.com/users/BBN-Q/orgs","repos_url":"https://api.github.com/users/BBN-Q/repos","events_url":"https://api.github.com/users/BBN-Q/events{/privacy}","received_events_url":"https://api.github.com/users/BBN-Q/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BBN-Q/libaps2","description":"C/C++ driver for BBN APSv2","fork":false,"url":"https://api.github.com/repos/BBN-Q/libaps2","forks_url":"https://api.github.com/repos/BBN-Q/libaps2/forks","keys_url":"https://api.github.com/repos/BBN-Q/libaps2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BBN-Q/libaps2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BBN-Q/libaps2/teams","hooks_url":"https://api.github.com/repos/BBN-Q/libaps2/hooks","issue_events_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/events{/number}","events_url":"https://api.github.com/repos/BBN-Q/libaps2/events","assignees_url":"https://api.github.com/repos/BBN-Q/libaps2/assignees{/user}","branches_url":"https://api.github.com/repos/BBN-Q/libaps2/branches{/branch}","tags_url":"https://api.github.com/repos/BBN-Q/libaps2/tags","blobs_url":"https://api.github.com/repos/BBN-Q/libaps2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BBN-Q/libaps2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BBN-Q/libaps2/git/refs{/sha}","trees_url":"https://api.github.com/repos/BBN-Q/libaps2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BBN-Q/libaps2/statuses/{sha}","languages_url":"https://api.github.com/repos/BBN-Q/libaps2/languages","stargazers_url":"https://api.github.com/repos/BBN-Q/libaps2/stargazers","contributors_url":"https://api.github.com/repos/BBN-Q/libaps2/contributors","subscribers_url":"https://api.github.com/repos/BBN-Q/libaps2/subscribers","subscription_url":"https://api.github.com/repos/BBN-Q/libaps2/subscription","commits_url":"https://api.github.com/repos/BBN-Q/libaps2/commits{/sha}","git_commits_url":"https://api.github.com/repos/BBN-Q/libaps2/git/commits{/sha}","comments_url":"https://api.github.com/repos/BBN-Q/libaps2/comments{/number}","issue_comment_url":"https://api.github.com/repos/BBN-Q/libaps2/issues/comments{/number}","contents_url":"https://api.github.com/repos/BBN-Q/libaps2/contents/{+path}","compare_url":"https://api.github.com/repos/BBN-Q/libaps2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BBN-Q/libaps2/merges","archive_url":"https://api.github.com/repos/BBN-Q/libaps2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BBN-Q/libaps2/downloads","issues_url":"https://api.github.com/repos/BBN-Q/libaps2/issues{/number}","pulls_url":"https://api.github.com/repos/BBN-Q/libaps2/pulls{/number}","milestones_url":"https://api.github.com/repos/BBN-Q/libaps2/milestones{/number}","notifications_url":"https://api.github.com/repos/BBN-Q/libaps2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BBN-Q/libaps2/labels{/name}","releases_url":"https://api.github.com/repos/BBN-Q/libaps2/releases{/id}","deployments_url":"https://api.github.com/repos/BBN-Q/libaps2/deployments","created_at":"2014-07-18T01:25:57Z","updated_at":"2016-04-30T13:15:40Z","pushed_at":"2016-09-12T14:16:03Z","git_url":"git://github.com/BBN-Q/libaps2.git","ssh_url":"git@github.com:BBN-Q/libaps2.git","clone_url":"https://github.com/BBN-Q/libaps2.git","svn_url":"https://github.com/BBN-Q/libaps2","homepage":null,"size":4567,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85"},"html":{"href":"https://github.com/BBN-Q/libaps2/pull/85"},"issue":{"href":"https://api.github.com/repos/BBN-Q/libaps2/issues/85"},"comments":{"href":"https://api.github.com/repos/BBN-Q/libaps2/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BBN-Q/libaps2/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/BBN-Q/libaps2/statuses/cbc6a7f4a2a9991a38f0b8272d209c951eeecb4b"}}}}
{"actor":{"display_login":"blakejohnson"}}