f4dtr 16 Posted September 18, 2013 Share Posted September 18, 2013 Hi all !On another thread (cheat sheet thread), I have explain I use launchpad for driving a SI570. some of you have need I share my work. it's ok... ;-) look attachment file. For understand my work, i preconise to read the datasheet. The SI570 have 2 mode for change frequency, i use the "long" mode. I recalc all parameters in every change frequency. But i simplify the calcul by the systematic use of initial frequency in place of read all registers for determinize actual ferquency to recalc new freq. (I think attiny/softrock already uses this trick.) but, I have 2 problems (in Fxtal_init) , and 1 function not implemented (in SetFrequency). I do not have time to look for now. but this is a good example of driving SI570, all logic is present. this code is divide in function. the principal is : void Init_FXTAL( void ) => read and calcul your Fxtal. this frequency is different for every SI570... (98% finish, but not fonctionnal) void setFrequency(float FOUT_NEW) => Change to your frequency in parameters (Mhz) (80% finish but not fonctionnal) void Set10(void) => Set SI570 to 10Mhz. fonctionnal with my SI570. void Set20m(void) => loop frequency 20m band (13.5Mhz to 14.5 Mhz by 100Khz). fonctional with my SI570. first problem : uint64_t RFREQ_INIT = 0x0; RFREQ_INIT = ((i2cInitBuf[2] & 0x3F) << 32); RFREQ_INIT = RFREQ_INIT | (i2cReadBuf[3] << 24); RFREQ_INIT = RFREQ_INIT | (i2cReadBuf[4] << 16); RFREQ_INIT = RFREQ_INIT | (i2cReadBuf[5] << 8); RFREQ_INIT = RFREQ_INIT | i2cReadBuf[6]; this result is not good. i think i have a problem with "unsigned".... bug ? 2. Second problem : (float) RFREQ_MHZ_INIT = (uint64_t) RFREQ_INIT / 268435456; // 268435456 = 2^28 if RFREQ is ok but the result is wrong... lack precision ? rounded ? Fonction not implemented : for change frequency to all value, the N1_DIV and HS_DIV must be calculed before change registers. i not program this part, i expect my correction (or your ;-) ) of my precedents problems for think it. ;-) in clonclusion : this code is not finished, but I do not have time now.This version provides all the elements of SI570 register read/write register comprehension.I think many things can be improved, it is only a draft of a future library maybe. but for now, it allowed me to test my trap and filter. time spent / results and so far positive report.I probably would end one day, when I need more function, or more accurately. I hope that this code you'll help to understand the Si570. good luck! and if you made ??a full library, think warn me! ;-) more explain/comment in code, good read ! ;-) Jean-Yves F4DTR. ps: sorry for my bad english. if you don't understand mail me, or if you want to correct me (english or code), youre welcome ! si570.ino pimmel, energia and xv4y 3 Quote Link to post Share on other sites
oPossum 1,083 Posted September 18, 2013 Share Posted September 18, 2013 Try this: const uint64_t RFREQ_INIT = ((uint64_t)(i2cInitBuf[2] & 0x3F) << 32) | ((uint32_t)i2cReadBuf[3] << 24) | ((uint32_t)i2cReadBuf[4] << 16) | ((uint16_t)i2cReadBuf[5] << 8) | i2cReadBuf[6]; const float FREQ_MHZ_INIT = (float)RFEQ_INIT / 268435456.0; // 268435456 = 2^28 xv4y, energia and f4dtr 3 Quote Link to post Share on other sites
xv4y 46 Posted September 19, 2013 Share Posted September 19, 2013 Hi, Great work Jean-Yves. Thanks for sharing your code. I have no time to work on MSP430 right now being busy with other micro-controllers projects and a website development (http://www.qscope.org/). However, I will give it a try as soon as possible. 73, Yan - XV4Y. Quote Link to post Share on other sites
f4dtr 16 Posted September 19, 2013 Author Share Posted September 19, 2013 Hi, thanks oPossum ! i will try your good idea this night. Yan, if you want more detail in french, you can use my blog : http://f4dtr.wordpress.com/2013/09/18/pilotage-dun-si570-par-arduino-ou-energia/ but, i think you have already a good understanding to SI570, I do not pretend to innovate... bye, Jean-Yves. F4DTR. Quote Link to post Share on other sites
pimmel 5 Posted September 20, 2013 Share Posted September 20, 2013 Hi Jean-Yves, Looking over your code in the ino file, I think you might be writing to the wrong register to freeze the DCO; around line 167 you use register 135 instead of 137. Likewise for unfreezing the DCO. While some sample code I was playing around with didn't seem to matter for the register values I was playing with (jumping from 10 MHz to 14.2 MHz), the way I read the data sheet for the SI570 indicates that for large frequency change you should freeze 0b00010000 (0x10). So maybe use this instead? (untested - I was playing outside of energia): //Freeze DCO err |= SI570_WriteRegister(137, 16); Wire.beginTransmission(SI570); // ... // Unfreeze DCO err |= SI570_WriteRegister(137, 0); f4dtr 1 Quote Link to post Share on other sites
pimmel 5 Posted September 20, 2013 Share Posted September 20, 2013 By the way, thank you for posting this. Your code gave me enough information to debug my code so that I could do the initial setting of si570 and make sure that my I2C connections were going to the right place. I can't tell you how pumped I was when I saw my frequency meter jump to 14.2 MHz after reflashing the launchpad! Quote Link to post Share on other sites
f4dtr 16 Posted September 21, 2013 Author Share Posted September 21, 2013 Hi Jean-Yves, Looking over your code in the ino file, I think you might be writing to the wrong register to freeze the DCO; around line 167 you use register 135 instead of 137. Likewise for unfreezing the DCO. While some sample code I was playing around with didn't seem to matter for the register values I was playing with (jumping from 10 MHz to 14.2 MHz), the way I read the data sheet for the SI570 indicates that for large frequency change you should freeze 0b00010000 (0x10). So maybe use this instead? (untested - I was playing outside of energia): //Freeze DCO err |= SI570_WriteRegister(137, 16); Wire.beginTransmission(SI570); // ... // Unfreeze DCO err |= SI570_WriteRegister(137, 0); hi Pimmel, in P15 for the small change, it says : 1. Freeze the Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.