Jump to content
43oh

Change Frequency to SI570 DXO on I2C. (not fully fonctionnal).


Recommended Posts

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.
  1. 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

Link to post
Share on other sites

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
Link to post
Share on other sites

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);
    



Link to post
Share on other sites

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!

Link to post
Share on other sites

 

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 
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...