Thomas, Thanks for the data. Unfortunately, it may refuted my initial hunch. Given the problems that others are having in not being able to set the Si570's clock frequency, I am now wondering whether a significant error has been introduced into the radiono codebase. I will explain the code issues I have encountered. I am putting together test sketches for the Digi Board. The last test sketch is to test for the proper interfacing and control of the Si570 by the Arduino. I pulled the Si570 code modules from the radiono master (obtained on March 9th) to use in my test code. I found that my Si570's clock frequency would not change from the startup frequency of 10.000 MHz, even though I changed the startup frequency parameter when creating the 'vfo' object. From my initial investigation, I determined that the code used to determine the Si570's crystal frequency was not working properly. To verify this, I modified my code to directly select a new clock frequency (12.000 MHz) and not worry that the true crystal frequency was not known. I found that this did work. I turned my attention to the code that determines the crystal frequency. What I found was that the following pieces of code did not work as expected. The first is the assembly of the DCO Frequency (actually, this is the reference frequency), as listed on lines 81 through 95 in Si570.cpp: uint64_t Si570::getRfReq() { uint64_t dcoFrequency = 0; dcoFrequency = (uint64_t)(this->dco_reg[8] & 0x3F) << 32; dcoFrequency |= (uint64_t)this->dco_reg[9] << 24; dcoFrequency |= (uint64_t)this->dco_reg[10] << 16; dcoFrequency |= this->dco_reg[11] << 8; dcoFrequency |= this->dco_reg[12]; return dcoFrequency; } double Si570::getRfReqDouble() { return ((double) getRfReq() / ((uint64_t)1 << 28)); } It appears that the most significant bits (above bit 31) disappear. Perhaps unsigned, 64-bit shifts are not working properly. The second code bug appears to be the calculation of the crystal frequency (freq_xtal), as listed on line 43 in Si570.cpp:freq_xtal = (uint64_t)calibration_frequency * getHsDiv() * getN1() / getRfReqDouble();
It appears that unsigned, 64-bit multiplications are not working properly. I found that the following approaches did work for calculating the reference frequency and the crystal frequency. // Obtain the reference frequency value in hex. refFrequencyUint64 = (uint64_t)(dco_reg[8] & 0x3F); refFrequencyUint64 = (refFrequencyUint64 << 8) | (uint64_t) dco_reg[9]; refFrequencyUint64 = (refFrequencyUint64 << 8) | (uint64_t) dco_reg[10]; refFrequencyUint64 = (refFrequencyUint64 << 8) | (uint64_t) dco_reg[11]; refFrequencyUint64 = (refFrequencyUint64 << 8) | (uint64_t) dco_reg[12];// Convert to double and divide by 2^28 to get the reference frequency in MHz.
refFrequency = (double) refFrequencyUint64 / (double) 268435456.0;// Determine the DCO current frequency, based on the startup frequency, HS, and N1 values. dcoCurrentFrequency = (double) SI570_STARTUP_FREQUENCY * (double) hs_reg_value * (double) n_reg_value;
// Determine the more accurate crystal frequency. freqXtalDbl = dcoCurrentFrequency / refFrequency; freq_xtal = (unsigned long) freqXtalDbl; I have attached a zip file containing my si570_testing sketch for you to see the code snippets listed above in full context. The code uses the LCD to display intermediate results with long delays to examine and write down (if desired) each set of results. I am unsure if this is a shortcoming/bug in the Arduino 64-bit library or a problem with the Arduino programming language order of evaluation. The language appears to essentially be C++-like. I am currently using Arduino 1.0.5. 73, Mac AE5PH BTW Here are the register values I obtained from my Si570: Register[7] = ad Register[8] = 42 Register[9] = a8 Register[10] = db Register[11] = fe Register[12] = 17 HS = 9, N1 = 54 Reference Frequency (hex): 2A8DBFE17 Reference Frequency (double): 42.553710 Crystal Frequency (long int): 114208608 (Hz) On 03/19/2014 01:00 AM, Thomas Sarlandie wrote:
Mac,This is what I get on the serial port when I start my Minima (Settings are 115200-8-N-1):Radiono starting! Successfully initialized Si570 --- Si570 Debug Info --- Crystal frequency calibrated at: 114347712 Status: 1 Register[7] = e1 Register[8] = c2 Register[9] = b5 Register[10] = 7c Register[11] = 77 Register[12] = 70 Register[13] = 00 Register[14] = 00 HsDivider = 11 N1 = 8 Reference Frequency (hex) : 0002b57c7770 Reference Frequency (double): 43.343If your Si570 startup frequency is not 56.320 Mhz, you should just need to change line 126 of radiono.ino and pass your actual startup frequency. I was not able to test this so maybe I missed something. I would love to know more about the bug you are after!73, thomasOn Tue, Mar 18, 2014 at 9:19 PM, Mac A. Cody <maccody@xxxxxxx <mailto:maccody@xxxxxxx>>wrote:Thanks, Thomas! 73, Mac AE5PH On 03/18/2014 12:24 PM, Thomas Sarlandie wrote:Frank, There is nothing stored in EEPROM at the moment. Can you look at the serial console when you start it and copy/paste the messages you get? It will help us understand what is going on. Mac, Sorry could not look at my registers last night but I will send you that tonight. 73, thomas On Tue, Mar 18, 2014 at 4:02 AM, Frank <w4nhj@xxxxxxxxxxx <mailto:w4nhj@xxxxxxxxxxx>>wrote: Jerry and All, I am having the same problem. I went back to the original program and the same thing. I wonder if something is being stored in EEProm and messing things up when you restart. I was suspecting my SI570 was bad, maybe not now that someone else is having the same problem. Frank - W4NHJ - On 3/18/14, 3:09 AM, jerry@xxxxxxxxxxxxxxxx <mailto:jerry@xxxxxxxxxxxxxxxx>wrote:I have just downloaded the new .03 version of the code and for some reason I can no longer tune around. The display shows the frequency changing, but it's not really changing. I have the 56.32 startup freq in my Si570 in my rig. How do I get the register values you need, are these the values on pins 7 thru 12? Jerry K5LRU Harwood, Texas-------- Original Message -------- Subject: [minima] Acting on a hunch - Si570 programming code bug From: "Mac A. Cody"<maccody@xxxxxxx> <mailto:maccody@xxxxxxx> Date: Mon, March 17, 2014 9:44 pm To:minima@xxxxxxxxxxxxx <mailto:minima@xxxxxxxxxxxxx> Greetings, During the development of my Minima construction guide, I think I may have found some errors in the code to set the Si570 VFO frequency. My Si570 has a startup frequency of 10.00 MHz, versus the usual 'ham' Si570 that has a startup frequency of 56.32 MHz. I believe that I have fixed one of the code errors and I have a hunch as to why the original code failed. In order to verify my hunch, would it be possible for someone with a Si570 with the 56.32 MHz startup frequency to post the initial values they obtain for registers 7 through 12? From those values, I can extract the values for HS, N1, and RFREQ for their Si570 and either verify or refute my hunch. Thanks and 73, Mac AE5PH
Attachment:
si570_testing.zip
Description: Zip archive