Jack Purdum
Around line 275 in the Raduino.ino file are a series of calls that write the calibration number to EEPROM as a long?data type to the first 4 bytes of EEPROM. What's interesting is that there is no EEPROM.read() call in the code to fetch it on power up. Unless there is some way to write the offset to the Si5351, I don't understand what the EEPROM.write() is for. Also, the current code makes the programmer know (guess??) whether numbers are stored Big Endian or Little Endian.? A more portable and easier way would be?in the calibrate() function: ? ? ? cal = (cal * 10000000l) / frequency; ? ? ? EEPROM.put(0, cal); ? ? ?????????????//Write the 4 bytes into the eeprom memory at location 0 ? ? ? //cal = (cal * 10000000l) / frequency; ? ? ? ? ? ?// Original code... ? ? ? //Write the 4 bytes into the eeprom memory. ? ? ? //EEPROM.write(0, (cal & 0xFF)); ? ? ? //EEPROM.write(1, ((cal >> 8) & 0xFF)); ? ? ? //EEPROM.write(2, ((cal >> 16) & 0xFF)); ? ? ? //EEPROM.write(3, ((cal >> 24) & 0xFF)); When you need to retrieve cal, use: ? ? ? ? EEPROM.get(0, cal); ? ? ? ? ? ? ? ?// Read 4 bytes from EEPROM at memory address 0 This might even save a few bytes of code space. The put() and get() methods work because the underlying C++ compiler can use indirection without the address-of operator (&) by using the variable as a reference object.? Also, don't forget to replace sprintf() in the code, which will also save some code space. (That was discussed in an earlier post.)? I haven't read through the code closely enough to see how the calibrate() function works. However, unless that result is stored in EEPROM or some other non-volatile code space, I don't see how it works on subsequent powerups. Jack, W8TEE From: Dr Fred Hambrecht <AAR4MI@...> To: [email protected] Sent: Wednesday, February 15, 2017 1:48 PM Subject: Re: [BITX20] Calibration Rob, It appears the correction is saved in the first bytes of EEprom and used internally by the Si5351. It is not called by the program as it is an external process. I am sure one of the Gurus can elucidate further. ? v/r Fred W4JLE ? ? ? From: [email protected] [mailto:[email protected]] On Behalf Of G4NQX Sent: Wednesday, February 15, 2017 13:33 To: [email protected] Subject: [BITX20] Calibration ? Have any of you run the calibration successfully, by that I mean does it stick after powerdown.? I don't believe it can due to the code but I'm confirming this with Jack. I ran a test setup on the bench and it doesn't work either with the old or new si5351 library. It will calibrate and maybe write to eeprom but it doesn't appear to get called. -- Rob G4NQX |